xtend
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "xtend", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "extend like a boss", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -9,56 +9,14 @@ # xtend | ||
Basic usage: | ||
<a href="https://runnable.com/#raynos/xtend-basic/app.js/launch" target="_blank"><img src="https://runnable.com/external/styles/assets/runnablebtn.png" style="width:67px;height:25px;"></a> | ||
```js | ||
var extend = require("xtend") | ||
var extend = require('xtend'), | ||
a = { | ||
'I': 'am' | ||
}, | ||
b = { | ||
'a': 'boss' | ||
}; | ||
var combination = extend({ | ||
a: "a" | ||
}, { | ||
b: "b" | ||
}) | ||
// { a: "a", b: "b" } | ||
``` | ||
extend(a, b); | ||
console.log('I ', a.I, ' a ', a.a); | ||
Extend with multiple objects: | ||
<a href="https://runnable.com/#raynos/xtend-multiple/app.js/launch" target="_blank"><img src="https://runnable.com/external/styles/assets/runnablebtn.png" style="width:67px;height:25px;"></a> | ||
var extend = require('xtend'), | ||
a = { | ||
'w': 'I' | ||
}, | ||
b = { | ||
'x': 'am' | ||
}, | ||
c = { | ||
'y': 'a' | ||
}, | ||
d = { | ||
'z': 'boss' | ||
} | ||
boss = extend({}, a, b, c, d); | ||
console.log(boss.w, ' ', boss.x, ' ', boss.y, ' ', boss.z); | ||
Right-most precendence: | ||
<a href="https://runnable.com/#raynos/xtend-rightmost/app.js/launch" target="_blank"><img src="https://runnable.com/external/styles/assets/runnablebtn.png" style="width:67px;height:25px;"></a> | ||
var extend = require("xtend"), | ||
a = { | ||
"p": 1 | ||
}, | ||
b = { | ||
"p": 2 | ||
} | ||
c = { | ||
"p": 3 | ||
}, | ||
boss = extend({}, a, b, c); | ||
console.log(boss.p); // Logs 3 | ||
## MIT Licenced | ||
## MIT Licenced |
4540
22