> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/function/wrap.md).

# \_.wrap

**语法：**

```javascript
_.wrap(value, [wrapper=identity])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L10955)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.wrap)

**描述：**

创建一个函数。提供的`value`包装在 wrapper 函数的第一个参数里。 任何附加的参数都提供给 wrapper 函数。 被调用时`this`绑定在创建的函数上。

**开始版本：**&#x30;.1.0

**参数：**

* `value (*)`: 要包装的值。
* `[wrapper=identity] (Function)`: 包装函数。

**返回值：**

* `(Function)`: 返回新的函数。

**例子：**

```javascript
var p = _.wrap(_.escape, function(func, text) {
  return '<p>' + func(text) + '</p>';
});

p('fred, barney, & pebbles');
// => '<p>fred, barney, &amp; pebbles</p>'
```
