Travis build: 1441
This commit is contained in:
36
README.md
36
README.md
@ -304,6 +304,7 @@ average(1, 2, 3);
|
|||||||
<details>
|
<details>
|
||||||
<summary>View contents</summary>
|
<summary>View contents</summary>
|
||||||
|
|
||||||
|
* [`bindAll`](#bindall)
|
||||||
* [`deepClone`](#deepclone)
|
* [`deepClone`](#deepclone)
|
||||||
* [`defaults`](#defaults)
|
* [`defaults`](#defaults)
|
||||||
* [`equals`](#equals-)
|
* [`equals`](#equals-)
|
||||||
@ -5100,6 +5101,41 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
|
|||||||
---
|
---
|
||||||
## 🗃️ Object
|
## 🗃️ Object
|
||||||
|
|
||||||
|
### bindAll
|
||||||
|
|
||||||
|
Explain briefly what the snippet does.
|
||||||
|
|
||||||
|
Use `Array.forEach()` to return a `function` that uses `Function.apply()` to apply the given context (`obj`) to `fn` for each function specified.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const bindAll = (obj, ...fns) =>
|
||||||
|
fns.forEach(
|
||||||
|
fn =>
|
||||||
|
(obj[fn] = function() {
|
||||||
|
return fn.apply(obj);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
var view = {
|
||||||
|
label: 'docs',
|
||||||
|
click: function() {
|
||||||
|
console.log('clicked ' + this.label);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bindAll(view, 'click');
|
||||||
|
jQuery(element).on('click', view.click); // Logs 'clicked docs' when clicked.
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### deepClone
|
### deepClone
|
||||||
|
|
||||||
Creates a deep clone of an object.
|
Creates a deep clone of an object.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -16,8 +16,8 @@ const bindAll = (obj, ...fns) =>
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
var view = {
|
var view = {
|
||||||
'label': 'docs',
|
label: 'docs',
|
||||||
'click': function() {
|
click: function() {
|
||||||
console.log('clicked ' + this.label);
|
console.log('clicked ' + this.label);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -215,7 +215,7 @@ sortedLastIndexBy:array,math,function
|
|||||||
splitLines:string
|
splitLines:string
|
||||||
spreadOver:adapter
|
spreadOver:adapter
|
||||||
standardDeviation:math,array
|
standardDeviation:math,array
|
||||||
stripHTMLTags:string,utility,regexp
|
stripHTMLtags:uncategorized
|
||||||
sum:math,array
|
sum:math,array
|
||||||
sumBy:math,array,function
|
sumBy:math,array,function
|
||||||
sumPower:math
|
sumPower:math
|
||||||
|
|||||||
Reference in New Issue
Block a user