pax_global_header 0000666 0000000 0000000 00000000064 13267352557 0014531 g ustar 00root root 0000000 0000000 52 comment=499fff4a846c970336ebce9cdf6d2f3b89dda102
node-extend-shallow-3.0.2/ 0000775 0000000 0000000 00000000000 13267352557 0015414 5 ustar 00root root 0000000 0000000 node-extend-shallow-3.0.2/.editorconfig 0000664 0000000 0000000 00000000441 13267352557 0020070 0 ustar 00root root 0000000 0000000 # http://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[{**/{actual,fixtures,expected,templates}/**,*.md}]
trim_trailing_whitespace = false
insert_final_newline = false
node-extend-shallow-3.0.2/.eslintrc.json 0000664 0000000 0000000 00000006775 13267352557 0020227 0 ustar 00root root 0000000 0000000 {
"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": true
},
"globals": {
"document": false,
"navigator": false,
"window": false
},
"rules": {
"accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-dangle": [2, "never"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [2, "^(err|error)$" ],
"indent": [2, 2, { "SwitchCase": 1 }],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 0,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-proto": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 0,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-useless-call": 0,
"no-with": 2,
"one-var": [0, { "initialized": "never" }],
"operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [0, "never"],
"quotes": [2, "single", "avoid-escape"],
"radix": 2,
"semi": [2, "always"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yoda": [2, "never"]
}
}
node-extend-shallow-3.0.2/.gitattributes 0000664 0000000 0000000 00000000177 13267352557 0020314 0 ustar 00root root 0000000 0000000 # Enforce Unix newlines
* text eol=lf
# binaries
*.ai binary
*.psd binary
*.jpg binary
*.gif binary
*.png binary
*.jpeg binary node-extend-shallow-3.0.2/.gitignore 0000664 0000000 0000000 00000000446 13267352557 0017410 0 ustar 00root root 0000000 0000000 # always ignore files
*.DS_Store
.idea
*.sublime-*
# test related, or directories generated by tests
test/actual
actual
coverage
.nyc*
# npm
node_modules
npm-debug.log
# yarn
yarn.lock
yarn-error.log
# misc
_gh_pages
_draft
_drafts
bower_components
vendor
temp
tmp
TODO.md
package-lock.json node-extend-shallow-3.0.2/.travis.yml 0000664 0000000 0000000 00000000214 13267352557 0017522 0 ustar 00root root 0000000 0000000 sudo: false
os:
- linux
- osx
language: node_js
node_js:
- node
- '9'
- '8'
- '7'
- '6'
- '5'
- '4'
- '0.12'
- '0.10'
node-extend-shallow-3.0.2/.verb.md 0000664 0000000 0000000 00000000342 13267352557 0016751 0 ustar 00root root 0000000 0000000 ## Usage
```js
var extend = require('{%= name %}');
extend({a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
```
Pass an empty object to shallow clone:
```js
var obj = {};
extend(obj, {a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
```
node-extend-shallow-3.0.2/LICENSE 0000664 0000000 0000000 00000002106 13267352557 0016420 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2014-2015, 2017, Jon Schlinkert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
node-extend-shallow-3.0.2/README.md 0000664 0000000 0000000 00000010765 13267352557 0016704 0 ustar 00root root 0000000 0000000 # extend-shallow [](https://www.npmjs.com/package/extend-shallow) [](https://npmjs.org/package/extend-shallow) [](https://npmjs.org/package/extend-shallow) [](https://travis-ci.org/jonschlinkert/extend-shallow)
> Extend an object with the properties of additional objects. node.js/javascript util.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save extend-shallow
```
## Usage
```js
var extend = require('extend-shallow');
extend({a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
```
Pass an empty object to shallow clone:
```js
var obj = {};
extend(obj, {a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
```
## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Related projects
You might also be interested in these projects:
* [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow "Extend an object with the properties of additional objects. node.js/javascript util.")
* [for-in](https://www.npmjs.com/package/for-in): Iterate over the own and inherited enumerable properties of an object, and return an object… [more](https://github.com/jonschlinkert/for-in) | [homepage](https://github.com/jonschlinkert/for-in "Iterate over the own and inherited enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js")
* [for-own](https://www.npmjs.com/package/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own) | [homepage](https://github.com/jonschlinkert/for-own "Iterate over the own enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js.")
* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.")
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 33 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [pdehaan](https://github.com/pdehaan) |
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 19, 2017._ node-extend-shallow-3.0.2/benchmark/ 0000775 0000000 0000000 00000000000 13267352557 0017346 5 ustar 00root root 0000000 0000000 node-extend-shallow-3.0.2/benchmark/code/ 0000775 0000000 0000000 00000000000 13267352557 0020260 5 ustar 00root root 0000000 0000000 node-extend-shallow-3.0.2/benchmark/code/1-1-4.js 0000664 0000000 0000000 00000001253 13267352557 0021256 0 ustar 00root root 0000000 0000000 'use strict';
var typeOf = require('kind-of');
/**
* Expose `extend`
*/
module.exports = extend;
/**
* Extend `o` with properties of other `objects`.
*
* @param {Object} `o` The target object. Pass an empty object to shallow clone.
* @param {Object} `objects`
* @return {Object}
*/
function extend(o) {
if (typeOf(o) !== 'object') { return {}; }
var args = arguments;
var len = args.length - 1;
for (var i = 0; i < len; i++) {
var obj = args[i + 1];
if (typeOf(obj) === 'object' && typeOf(obj) !== 'regexp') {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/assign.js 0000664 0000000 0000000 00000000646 13267352557 0022110 0 ustar 00root root 0000000 0000000
var isObject = require('is-extendable');
module.exports = function extend(a, b) {
if (!a) return {};
if (!b) return a;
var len = arguments.length - 1, i = 1;
while (len--) {
var obj = arguments[i++];
if (isObject(obj)) {
assign(a, obj);
}
}
return a;
};
function assign(o, obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
return o;
}
node-extend-shallow-3.0.2/benchmark/code/extend-shallow.js 0000664 0000000 0000000 00000000062 13267352557 0023552 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = require('../..');
node-extend-shallow-3.0.2/benchmark/code/for-arguments-in.js 0000664 0000000 0000000 00000000572 13267352557 0024017 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) { o = {}; }
var len = arguments.length;
for (var i = 1; i < len; i++) {
var obj = arguments[i];
if (isObject(obj)) {
assign(o, obj);
}
}
return o;
};
function assign(a, b) {
for (var key in b) {
a[key] = b[key];
}
}
node-extend-shallow-3.0.2/benchmark/code/for-arguments.js 0000664 0000000 0000000 00000000637 13267352557 0023415 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-plain-object');
module.exports = function extend(o, objects) {
if (!o || !objects) { return o || {}; }
var len = arguments.length - 1;
for (var i = 0; i < len; i++) {
var obj = arguments[i + 1];
if (isObject(obj)) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/for-each.js 0000664 0000000 0000000 00000000570 13267352557 0022304 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) {o = {};}
var args = [].slice.call(arguments);
args.forEach(function (obj) {
if (isObject(obj)) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
});
return o;
};
node-extend-shallow-3.0.2/benchmark/code/for-negative.js 0000664 0000000 0000000 00000000640 13267352557 0023204 0 ustar 00root root 0000000 0000000 'use strict';
var slice = require('array-slice');
module.exports = function extend(o, objects) {
if (o == null) { return {}; }
if (objects == null) { return o; }
var args = slice(arguments, 1);
var len = args.length - 1;
for (var i = len; i >= 0; i--) {
var obj = args[i];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
return o;
}; node-extend-shallow-3.0.2/benchmark/code/for-own-lib.js 0000664 0000000 0000000 00000000637 13267352557 0022757 0 ustar 00root root 0000000 0000000 'use strict';
var slice = require('array-slice');
var forOwn = require('for-own');
module.exports = function extend(o, objects) {
if (o == null) { return {}; }
if (objects == null) { return o; }
var args = slice(arguments, 1);
var len = args.length;
for (var i = 0; i < len; i++) {
var obj = args[i];
forOwn(obj, function (value, key) {
this[key] = value;
}, o);
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/for-own-slice-call.js 0000664 0000000 0000000 00000000602 13267352557 0024211 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function extend(o, objects) {
if (o == null) { return {}; }
if (objects == null) { return o; }
var args = [].slice.call([], arguments, 1);
var len = args.length;
for (var i = 0; i < len; i++) {
var obj = args[i];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/for-own.js 0000664 0000000 0000000 00000000634 13267352557 0022210 0 ustar 00root root 0000000 0000000 'use strict';
var slice = require('array-slice');
module.exports = function extend(o, objects) {
if (o == null) { return {}; }
if (objects == null) { return o; }
var args = slice(arguments, 1);
var len = args.length;
for (var i = 0; i < len; i++) {
var obj = args[i];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/for-prop-in.js 0000664 0000000 0000000 00000000555 13267352557 0022773 0 ustar 00root root 0000000 0000000 'use strict';
var slice = require('array-slice');
module.exports = function extend(o, objects) {
if (o == null) { return {}; }
if (objects == null) { return o; }
var args = slice(arguments, 1);
var len = args.length;
for (var i = 0; i < len; i++) {
var obj = args[i];
for (var key in obj) {
o[key] = obj[key];
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/for-slice-call-in.js 0000664 0000000 0000000 00000000523 13267352557 0024016 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function extend(o, objects) {
if (o == null) { return {}; }
if (objects == null) { return o; }
var args = [].slice.call([], arguments, 1);
var len = args.length;
for (var i = 0; i < len; i++) {
var obj = args[i];
for (var key in obj) {
o[key] = obj[key];
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/for.js 0000664 0000000 0000000 00000000610 13267352557 0021401 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) {o = {};}
var len = arguments.length;
for (var i = 1; i < len; i++) {
var obj = arguments[i];
if (isObject(obj)) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/object-assign.js 0000664 0000000 0000000 00000000072 13267352557 0023345 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = require('object-assign');
node-extend-shallow-3.0.2/benchmark/code/reduce.js 0000664 0000000 0000000 00000000617 13267352557 0022071 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) {o = {};}
var args = [].slice.call(arguments, 1);
return args.reduce(function (acc, val, i) {
if (isObject(val)) {
for (var key in val) {
if (val.hasOwnProperty(key)) {
acc[key] = val[key];
}
}
}
return acc;
}, o);
};
node-extend-shallow-3.0.2/benchmark/code/while-arguments-in.js 0000664 0000000 0000000 00000000522 13267352557 0024334 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) { o = {}; }
var len = arguments.length, i = 1;
while (len--) {
var obj = arguments[i++];
if (isObject(obj)) {
for (var key in obj) {
o[key] = obj[key];
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/while-for-own.js 0000664 0000000 0000000 00000000757 13267352557 0023324 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) {o = {};}
var len = arguments.length;
var i = 1;
while (len--) {
var obj = arguments[i++];
if (isObject(obj)) {
var keys = Object.keys(obj);
var klen = keys.length;
for (var j = 0; j < klen; j++) {
var key = keys[j];
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/while-for.js 0000664 0000000 0000000 00000000674 13267352557 0022521 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) {o = {};}
var len = arguments.length;
var i = 1;
while (len--) {
var obj = arguments[i++];
if (isObject(obj)) {
var keys = Object.keys(obj);
var klen = keys.length;
for (var j = 0; j < klen; j++) {
var key = keys[j];
o[key] = obj[key];
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/while-while.js 0000664 0000000 0000000 00000000665 13267352557 0023043 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) {o = {};}
var len = arguments.length;
var i = 1;
while (len--) {
var obj = arguments[i++];
if (isObject(obj)) {
var keys = Object.keys(obj);
var klen = keys.length, j = 0;
while (klen--) {
var key = keys[j++];
o[key] = obj[key];
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/while-while2.js 0000664 0000000 0000000 00000000660 13267352557 0023120 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = function extend(o, objects) {
if (!isObject(o)) {o = {};}
var len = arguments.length;
var i = 1;
while (len--) {
var obj = arguments[i++];
if (isObject(obj)) {
var keys = Object.keys(obj);
var klen = keys.length, j = 0;
var key;
while (key = keys[j++]) {
o[key] = obj[key];
}
}
}
return o;
};
node-extend-shallow-3.0.2/benchmark/code/while.js 0000664 0000000 0000000 00000000621 13267352557 0021725 0 ustar 00root root 0000000 0000000 'use strict';
var isObject = require('is-extendable');
module.exports = extend;
function extend(o, objects) {
if (!isObject(o)) {
o = {};
}
var len = arguments.length, i = 1;
while (len--) {
var obj = arguments[i++];
if (isObject(obj)) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
}
return o;
}
node-extend-shallow-3.0.2/benchmark/fixtures/ 0000775 0000000 0000000 00000000000 13267352557 0021217 5 ustar 00root root 0000000 0000000 node-extend-shallow-3.0.2/benchmark/fixtures/basic.js 0000664 0000000 0000000 00000000061 13267352557 0022633 0 ustar 00root root 0000000 0000000 module.exports = [{a: 'b'}, {c: 'd'}, {e: 'f'}];
node-extend-shallow-3.0.2/benchmark/fixtures/nested.js 0000664 0000000 0000000 00000000204 13267352557 0023033 0 ustar 00root root 0000000 0000000 module.exports = [
{a: 'a', m: {x: 'x'}},
{b: 'b', m: {x: 'q'}},
{c: 'c', m: {y: 'y'}},
{d: 'd', m: {z: 'z'}},
{d: 'e'}
]; node-extend-shallow-3.0.2/benchmark/fixtures/sparse.js 0000664 0000000 0000000 00000000171 13267352557 0023051 0 ustar 00root root 0000000 0000000 module.exports = [
{a: 'a', m: {x: 'x'}},
{b: 'b', m: {x: 'q'}},
'',
{d: 'd', m: {z: 'z'}},
null,
{d: 'e'}
]; node-extend-shallow-3.0.2/benchmark/index.js 0000664 0000000 0000000 00000000651 13267352557 0021015 0 ustar 00root root 0000000 0000000 'use strict';
const path = require('path');
const argv = require('minimist')(process.argv.slice(2));
const suite = require('benchmarked');
const glob = argv._[0] || '*';
suite.run({code: `code/${glob}.js`, fixtures: `fixtures/*.js`})
.then(function(stats) {
stats.forEach(function(target) {
target.fastest = target.fastest || ['n/a'];
});
console.log(suite.render(stats));
})
.catch(console.error);
node-extend-shallow-3.0.2/bower.json 0000664 0000000 0000000 00000002560 13267352557 0017430 0 ustar 00root root 0000000 0000000 {
"name": "extend-shallow",
"description": "Extend an object with the properties of additional objects. node.js/javascript util.",
"repository": "jonschlinkert/extend-shallow",
"license": "MIT",
"homepage": "https://github.com/jonschlinkert/extend-shallow",
"authors": [
"Jon Schlinkert (https://github.com/jonschlinkert)"
],
"main": [
"index.js"
],
"dependencies": {
"is-extendable": "^1.0.1"
},
"devDependencies": {
"array-slice": "^1.0.0",
"benchmarked": "^2.0.0",
"for-own": "^1.0.0",
"gulp-format-md": "^1.0.0",
"is-plain-object": "^2.0.4",
"kind-of": "^6.0.1",
"minimist": "^1.2.0",
"mocha": "^3.5.3",
"object-assign": "^4.1.1"
},
"keywords": [
"assign",
"clone",
"extend",
"merge",
"obj",
"object",
"object-assign",
"object.assign",
"prop",
"properties",
"property",
"props",
"shallow",
"util",
"utility",
"utils",
"value"
],
"version": "2.0.1",
"bugs": {
"url": "https://github.com/jonschlinkert/extend-shallow/issues"
},
"files": [
"index.js"
],
"ignore": [
"actual",
"bower_components",
"fixtures",
"node_modules",
"temp",
"test",
"test.js",
"tmp"
],
"contributors": [
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
"Peter deHaan (http://about.me/peterdehaan)"
]
} node-extend-shallow-3.0.2/index.js 0000664 0000000 0000000 00000002275 13267352557 0017067 0 ustar 00root root 0000000 0000000 'use strict';
var isExtendable = require('is-extendable');
var assignSymbols = require('assign-symbols');
module.exports = Object.assign || function(obj/*, objects*/) {
if (obj === null || typeof obj === 'undefined') {
throw new TypeError('Cannot convert undefined or null to object');
}
if (!isObject(obj)) {
obj = {};
}
for (var i = 1; i < arguments.length; i++) {
var val = arguments[i];
if (isString(val)) {
val = toObject(val);
}
if (isObject(val)) {
assign(obj, val);
assignSymbols(obj, val);
}
}
return obj;
};
function assign(a, b) {
for (var key in b) {
if (hasOwn(b, key)) {
a[key] = b[key];
}
}
}
function isString(val) {
return (val && typeof val === 'string');
}
function toObject(str) {
var obj = {};
for (var i in str) {
obj[i] = str[i];
}
return obj;
}
function isObject(val) {
return (val && typeof val === 'object') || isExtendable(val);
}
/**
* Returns true if the given `key` is an own property of `obj`.
*/
function hasOwn(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
function isEnum(obj, key) {
return Object.prototype.propertyIsEnumerable.call(obj, key);
}
node-extend-shallow-3.0.2/package.json 0000664 0000000 0000000 00000003254 13267352557 0017706 0 ustar 00root root 0000000 0000000 {
"name": "extend-shallow",
"description": "Extend an object with the properties of additional objects. node.js/javascript util.",
"version": "3.0.2",
"homepage": "https://github.com/jonschlinkert/extend-shallow",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
"Peter deHaan (http://about.me/peterdehaan)"
],
"repository": "jonschlinkert/extend-shallow",
"bugs": {
"url": "https://github.com/jonschlinkert/extend-shallow/issues"
},
"license": "MIT",
"files": [
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"dependencies": {
"assign-symbols": "^1.0.0",
"is-extendable": "^1.0.1"
},
"devDependencies": {
"array-slice": "^1.0.0",
"benchmarked": "^2.0.0",
"for-own": "^1.0.0",
"gulp-format-md": "^1.0.0",
"is-plain-object": "^2.0.4",
"kind-of": "^6.0.1",
"minimist": "^1.2.0",
"mocha": "^3.5.3",
"object-assign": "^4.1.1"
},
"keywords": [
"assign",
"clone",
"extend",
"merge",
"obj",
"object",
"object-assign",
"object.assign",
"prop",
"properties",
"property",
"props",
"shallow",
"util",
"utility",
"utils",
"value"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"related": {
"list": [
"extend-shallow",
"for-in",
"for-own",
"is-plain-object",
"isobject",
"kind-of"
]
},
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
}
}
}
node-extend-shallow-3.0.2/test.js 0000664 0000000 0000000 00000005340 13267352557 0016733 0 ustar 00root root 0000000 0000000 /*!
* extend-shallow
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
require('mocha');
var hasSymbol = typeof global.Symbol === 'function';
var path = require('path');
var argv = require('minimist')(process.argv.slice(2));
var assert = require('assert');
var extend = require('./');
if (argv && argv.lib) {
extend = require(path.resolve('benchmark/code', argv.lib));
}
describe('extend', function() {
it('should extend the first object with the properties of the other objects', function() {
assert.deepEqual(extend({a: 'b'}, {c: 'd'}), {a: 'b', c: 'd'});
assert.deepEqual(extend({a: 'b', c: 'd'}, {c: 'e'}), {a: 'b', c: 'e'});
});
it('should handle non-plain objects', function() {
assert.deepEqual(extend({a: 'b'}, 'foo', {c: 'd'}), {0: 'f', 1: 'o', 2: 'o', a: 'b', c: 'd'});
assert.deepEqual(extend({a: 'b'}, null, {c: 'd'}), {a: 'b', c: 'd'});
assert.deepEqual(extend({a: 'b'}, new Date(), {c: 'd'}), {a: 'b', c: 'd'});
});
it('should extend a regex', function() {
var fixture = /foo/;
extend(fixture, {a: 'b'}, new Date(), {c: 'd'});
assert.equal(fixture.a, 'b');
assert.equal(fixture.c, 'd');
});
it('should extend a function', function() {
var fixture = function() {};
extend(fixture, {a: 'b'}, new Date(), {c: 'd'});
assert.equal(fixture.a, 'b');
assert.equal(fixture.c, 'd');
});
it('should extend an array', function() {
var arr = [];
extend(arr, {a: 'b'}, new Date(), {c: 'd'});
assert.equal(arr.a, 'b');
assert.equal(arr.c, 'd');
});
it('should throw when the first arg is invalid', function() {
assert.throws(function() {
extend(null);
});
assert.throws(function() {
extend(undefined);
});
assert.throws(function() {
extend();
});
});
it('should return an empty object when non-object is passed', function() {
assert.deepEqual(extend(123), {});
});
it('should not extend non-enumerable symbols', function() {
if (!hasSymbol) return this.skip();
var fixture = {};
var obj = {};
var symbol = Symbol('foo');
Object.defineProperty(obj, symbol, {enumerable: false, value: 'bar'});
extend(fixture, obj);
var other = extend({}, obj);
assert.equal(typeof fixture[symbol], 'undefined');
assert.equal(typeof other[symbol], 'undefined');
});
it('should extend symbol properties', function() {
if (!hasSymbol) return this.skip();
var fixture = {};
var obj = {};
var symbol = Symbol('foo');
obj[symbol] = 'bar';
extend(fixture, obj);
var other = extend({}, obj);
assert.equal(fixture[symbol], 'bar');
assert.equal(other[symbol], 'bar');
});
});