pax_global_header00006660000000000000000000000064133241527250014516gustar00rootroot0000000000000052 comment=8d106d23931c0802e8b88188b0aac433e13358d9 node-extend-3.0.2/000077500000000000000000000000001332415272500137325ustar00rootroot00000000000000node-extend-3.0.2/.eslintrc000066400000000000000000000006151332415272500155600ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "complexity": [2, 20], "eqeqeq": [2, "allow-null"], "func-name-matching": [1], "max-depth": [1, 4], "max-statements": [2, 26], "no-extra-parens": [1], "no-magic-numbers": [0], "no-restricted-syntax": [2, "BreakStatement", "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"], "sort-keys": [0], } } node-extend-3.0.2/.gitignore000066400000000000000000000001541332415272500157220ustar00rootroot00000000000000# gitignore node_modules # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock node-extend-3.0.2/.jscs.json000066400000000000000000000100001332415272500156340ustar00rootroot00000000000000{ "es3": true, "additionalRules": [], "requireSemicolons": true, "disallowMultipleSpaces": true, "disallowIdentifierNames": [], "requireCurlyBraces": { "allExcept": [], "keywords": ["if", "else", "for", "while", "do", "try", "catch"] }, "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], "disallowSpaceAfterKeywords": [], "disallowSpaceBeforeComma": true, "disallowSpaceAfterComma": false, "disallowSpaceBeforeSemicolon": true, "disallowNodeTypes": [ "DebuggerStatement", "LabeledStatement", "SwitchCase", "SwitchStatement", "WithStatement" ], "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, "requireSpaceBetweenArguments": true, "disallowSpacesInsideParentheses": true, "disallowSpacesInsideArrayBrackets": true, "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] }, "disallowSpaceAfterObjectKeys": true, "requireCommaBeforeLineBreak": true, "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], "requireSpaceAfterPrefixUnaryOperators": [], "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], "requireSpaceBeforePostfixUnaryOperators": [], "disallowSpaceBeforeBinaryOperators": [], "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "disallowSpaceAfterBinaryOperators": [], "disallowImplicitTypeConversion": ["binary", "string"], "disallowKeywords": ["with", "eval"], "requireKeywordsOnNewLine": [], "disallowKeywordsOnNewLine": ["else"], "requireLineFeedAtFileEnd": true, "disallowTrailingWhitespace": true, "disallowTrailingComma": true, "excludeFiles": ["node_modules/**", "vendor/**"], "disallowMultipleLineStrings": true, "requireDotNotation": { "allExcept": ["keywords"] }, "requireParenthesesAroundIIFE": true, "validateLineBreaks": "LF", "validateQuoteMarks": { "escape": true, "mark": "'" }, "disallowOperatorBeforeLineBreak": [], "requireSpaceBeforeKeywords": [ "do", "for", "if", "else", "switch", "case", "try", "catch", "finally", "while", "with", "return" ], "validateAlignedFunctionParameters": { "lineBreakAfterOpeningBraces": true, "lineBreakBeforeClosingBraces": true }, "requirePaddingNewLinesBeforeExport": true, "validateNewlineAfterArrayElements": { "maximum": 6 }, "requirePaddingNewLinesAfterUseStrict": true, "disallowArrowFunctions": true, "disallowMultiLineTernary": true, "validateOrderInObjectKeys": false, "disallowIdenticalDestructuringNames": true, "disallowNestedTernaries": { "maxLevel": 1 }, "requireSpaceAfterComma": { "allExcept": ["trailing"] }, "requireAlignedMultilineParams": false, "requireSpacesInGenerator": { "afterStar": true }, "disallowSpacesInGenerator": { "beforeStar": true }, "disallowVar": false, "requireArrayDestructuring": false, "requireEnhancedObjectLiterals": false, "requireObjectDestructuring": false, "requireEarlyReturn": false, "requireCapitalizedConstructorsNew": { "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] }, "requireImportAlphabetized": false, "requireSpaceBeforeObjectValues": true, "requireSpaceBeforeDestructuredValues": true, "disallowSpacesInsideTemplateStringPlaceholders": true, "disallowArrayDestructuringReturn": false, "requireNewlineBeforeSingleStatementsInIf": false, "disallowUnusedVariables": true, "requireSpacesInsideImportedObjectBraces": true, "requireUseStrict": true } node-extend-3.0.2/.npmignore000066400000000000000000000000041332415272500157230ustar00rootroot00000000000000testnode-extend-3.0.2/.npmrc000066400000000000000000000000231332415272500150450ustar00rootroot00000000000000package-lock=false node-extend-3.0.2/.travis.yml000066400000000000000000000153631332415272500160530ustar00rootroot00000000000000language: node_js os: - linux node_js: - "10.7" - "9.11" - "8.11" - "7.10" - "6.14" - "5.12" - "4.9" - "iojs-v3.3" - "iojs-v2.5" - "iojs-v1.8" - "0.12" - "0.10" - "0.8" before_install: - 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac' - 'nvm install-latest-npm' install: - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi' - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi' - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi' - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' sudo: false env: - TEST=true matrix: fast_finish: true include: - node_js: "lts/*" env: PRETEST=true - node_js: "lts/*" env: POSTTEST=true - node_js: "4" env: COVERAGE=true - node_js: "10.6" env: TEST=true ALLOW_FAILURE=true - node_js: "10.5" env: TEST=true ALLOW_FAILURE=true - node_js: "10.4" env: TEST=true ALLOW_FAILURE=true - node_js: "10.3" env: TEST=true ALLOW_FAILURE=true - node_js: "10.2" env: TEST=true ALLOW_FAILURE=true - node_js: "10.1" env: TEST=true ALLOW_FAILURE=true - node_js: "10.0" env: TEST=true ALLOW_FAILURE=true - node_js: "9.10" env: TEST=true ALLOW_FAILURE=true - node_js: "9.9" env: TEST=true ALLOW_FAILURE=true - node_js: "9.8" env: TEST=true ALLOW_FAILURE=true - node_js: "9.7" env: TEST=true ALLOW_FAILURE=true - node_js: "9.6" env: TEST=true ALLOW_FAILURE=true - node_js: "9.5" env: TEST=true ALLOW_FAILURE=true - node_js: "9.4" env: TEST=true ALLOW_FAILURE=true - node_js: "9.3" env: TEST=true ALLOW_FAILURE=true - node_js: "9.2" env: TEST=true ALLOW_FAILURE=true - node_js: "9.1" env: TEST=true ALLOW_FAILURE=true - node_js: "9.0" env: TEST=true ALLOW_FAILURE=true - node_js: "8.10" env: TEST=true ALLOW_FAILURE=true - node_js: "8.9" env: TEST=true ALLOW_FAILURE=true - node_js: "8.8" env: TEST=true ALLOW_FAILURE=true - node_js: "8.7" env: TEST=true ALLOW_FAILURE=true - node_js: "8.6" env: TEST=true ALLOW_FAILURE=true - node_js: "8.5" env: TEST=true ALLOW_FAILURE=true - node_js: "8.4" env: TEST=true ALLOW_FAILURE=true - node_js: "8.3" env: TEST=true ALLOW_FAILURE=true - node_js: "8.2" env: TEST=true ALLOW_FAILURE=true - node_js: "8.1" env: TEST=true ALLOW_FAILURE=true - node_js: "8.0" env: TEST=true ALLOW_FAILURE=true - node_js: "7.9" env: TEST=true ALLOW_FAILURE=true - node_js: "7.8" env: TEST=true ALLOW_FAILURE=true - node_js: "7.7" env: TEST=true ALLOW_FAILURE=true - node_js: "7.6" env: TEST=true ALLOW_FAILURE=true - node_js: "7.5" env: TEST=true ALLOW_FAILURE=true - node_js: "7.4" env: TEST=true ALLOW_FAILURE=true - node_js: "7.3" env: TEST=true ALLOW_FAILURE=true - node_js: "7.2" env: TEST=true ALLOW_FAILURE=true - node_js: "7.1" env: TEST=true ALLOW_FAILURE=true - node_js: "7.0" env: TEST=true ALLOW_FAILURE=true - node_js: "6.13" env: TEST=true ALLOW_FAILURE=true - node_js: "6.12" env: TEST=true ALLOW_FAILURE=true - node_js: "6.11" env: TEST=true ALLOW_FAILURE=true - node_js: "6.10" env: TEST=true ALLOW_FAILURE=true - node_js: "6.9" env: TEST=true ALLOW_FAILURE=true - node_js: "6.8" env: TEST=true ALLOW_FAILURE=true - node_js: "6.7" env: TEST=true ALLOW_FAILURE=true - node_js: "6.6" env: TEST=true ALLOW_FAILURE=true - node_js: "6.5" env: TEST=true ALLOW_FAILURE=true - node_js: "6.4" env: TEST=true ALLOW_FAILURE=true - node_js: "6.3" env: TEST=true ALLOW_FAILURE=true - node_js: "6.2" env: TEST=true ALLOW_FAILURE=true - node_js: "6.1" env: TEST=true ALLOW_FAILURE=true - node_js: "6.0" env: TEST=true ALLOW_FAILURE=true - node_js: "5.11" env: TEST=true ALLOW_FAILURE=true - node_js: "5.10" env: TEST=true ALLOW_FAILURE=true - node_js: "5.9" env: TEST=true ALLOW_FAILURE=true - node_js: "5.8" env: TEST=true ALLOW_FAILURE=true - node_js: "5.7" env: TEST=true ALLOW_FAILURE=true - node_js: "5.6" env: TEST=true ALLOW_FAILURE=true - node_js: "5.5" env: TEST=true ALLOW_FAILURE=true - node_js: "5.4" env: TEST=true ALLOW_FAILURE=true - node_js: "5.3" env: TEST=true ALLOW_FAILURE=true - node_js: "5.2" env: TEST=true ALLOW_FAILURE=true - node_js: "5.1" env: TEST=true ALLOW_FAILURE=true - node_js: "5.0" env: TEST=true ALLOW_FAILURE=true - node_js: "4.8" env: TEST=true ALLOW_FAILURE=true - node_js: "4.7" env: TEST=true ALLOW_FAILURE=true - node_js: "4.6" env: TEST=true ALLOW_FAILURE=true - node_js: "4.5" env: TEST=true ALLOW_FAILURE=true - node_js: "4.4" env: TEST=true ALLOW_FAILURE=true - node_js: "4.3" env: TEST=true ALLOW_FAILURE=true - node_js: "4.2" env: TEST=true ALLOW_FAILURE=true - node_js: "4.1" env: TEST=true ALLOW_FAILURE=true - node_js: "4.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.7" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.6" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.5" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.0" env: TEST=true ALLOW_FAILURE=true - node_js: "0.11" env: TEST=true ALLOW_FAILURE=true - node_js: "0.9" env: TEST=true ALLOW_FAILURE=true - node_js: "0.6" env: TEST=true ALLOW_FAILURE=true - node_js: "0.4" env: TEST=true ALLOW_FAILURE=true allow_failures: - os: osx - env: TEST=true ALLOW_FAILURE=true node-extend-3.0.2/CHANGELOG.md000066400000000000000000000053331332415272500155470ustar00rootroot000000000000003.0.2 / 2018-07-19 ================== * [Fix] Prevent merging `__proto__` property (#48) * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` * [Tests] up to `node` `v10.7`, `v9.11`, `v8.11`, `v7.10`, `v6.14`, `v4.9`; use `nvm install-latest-npm` 3.0.1 / 2017-04-27 ================== * [Fix] deep extending should work with a non-object (#46) * [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config` * [Tests] up to `node` `v7.9`, `v6.10`, `v4.8`; improve matrix * [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG. * [Docs] Add example to readme (#34) 3.0.0 / 2015-07-01 ================== * [Possible breaking change] Use global "strict" directive (#32) * [Tests] `int` is an ES3 reserved word * [Tests] Test up to `io.js` `v2.3` * [Tests] Add `npm run eslint` * [Dev Deps] Update `covert`, `jscs` 2.0.1 / 2015-04-25 ================== * Use an inline `isArray` check, for ES3 browsers. (#27) * Some old browsers fail when an identifier is `toString` * Test latest `node` and `io.js` versions on `travis-ci`; speed up builds * Add license info to package.json (#25) * Update `tape`, `jscs` * Adding a CHANGELOG 2.0.0 / 2014-10-01 ================== * Increase code coverage to 100%; run code coverage as part of tests * Add `npm run lint`; Run linter as part of tests * Remove nodeType and setInterval checks in isPlainObject * Updating `tape`, `jscs`, `covert` * General style and README cleanup 1.3.0 / 2014-06-20 ================== * Add component.json for browser support (#18) * Use SVG for badges in README (#16) * Updating `tape`, `covert` * Updating travis-ci to work with multiple node versions * Fix `deep === false` bug (returning target as {}) (#14) * Fixing constructor checks in isPlainObject * Adding additional test coverage * Adding `npm run coverage` * Add LICENSE (#13) * Adding a warning about `false`, per #11 * General style and whitespace cleanup 1.2.1 / 2013-09-14 ================== * Fixing hasOwnProperty bugs that would only have shown up in specific browsers. Fixes #8 * Updating `tape` 1.2.0 / 2013-09-02 ================== * Updating the README: add badges * Adding a missing variable reference. * Using `tape` instead of `buster` for tests; add more tests (#7) * Adding node 0.10 to Travis CI (#6) * Enabling "npm test" and cleaning up package.json (#5) * Add Travis CI. 1.1.3 / 2012-12-06 ================== * Added unit tests. * Ensure extend function is named. (Looks nicer in a stack trace.) * README cleanup. 1.1.1 / 2012-11-07 ================== * README cleanup. * Added installation instructions. * Added a missing semicolon 1.0.0 / 2012-04-08 ================== * Initial commit node-extend-3.0.2/LICENSE000066400000000000000000000020711332415272500147370ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014 Stefan Thomas 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-3.0.2/README.md000066400000000000000000000057321332415272500152200ustar00rootroot00000000000000[![Build Status][travis-svg]][travis-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] # extend() for Node.js [![Version Badge][npm-version-png]][npm-url] `node-extend` is a port of the classic extend() method from jQuery. It behaves as you expect. It is simple, tried and true. Notes: * Since Node.js >= 4, [`Object.assign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) now offers the same functionality natively (but without the "deep copy" option). See [ECMAScript 2015 (ES6) in Node.js](https://nodejs.org/en/docs/es6). * Some native implementations of `Object.assign` in both Node.js and many browsers (since NPM modules are for the browser too) may not be fully spec-compliant. Check [`object.assign`](https://www.npmjs.com/package/object.assign) module for a compliant candidate. ## Installation This package is available on [npm][npm-url] as: `extend` ``` sh npm install extend ``` ## Usage **Syntax:** extend **(** [`deep`], `target`, `object1`, [`objectN`] **)** *Extend one object with one or more others, returning the modified object.* **Example:** ``` js var extend = require('extend'); extend(targetObject, object1, object2); ``` Keep in mind that the target object will be modified, and will be returned from extend(). If a boolean true is specified as the first argument, extend performs a deep copy, recursively copying any objects it finds. Otherwise, the copy will share structure with the original object(s). Undefined properties are not copied. However, properties inherited from the object's prototype will be copied over. Warning: passing `false` as the first argument is not supported. ### Arguments * `deep` *Boolean* (optional) If set, the merge becomes recursive (i.e. deep copy). * `target` *Object* The object to extend. * `object1` *Object* The object that will be merged into the first. * `objectN` *Object* (Optional) More objects to merge into the first. ## License `node-extend` is licensed under the [MIT License][mit-license-url]. ## Acknowledgements All credit to the jQuery authors for perfecting this amazing utility. Ported to Node.js by [Stefan Thomas][github-justmoon] with contributions by [Jonathan Buchanan][github-insin] and [Jordan Harband][github-ljharb]. [travis-svg]: https://travis-ci.org/justmoon/node-extend.svg [travis-url]: https://travis-ci.org/justmoon/node-extend [npm-url]: https://npmjs.org/package/extend [mit-license-url]: http://opensource.org/licenses/MIT [github-justmoon]: https://github.com/justmoon [github-insin]: https://github.com/insin [github-ljharb]: https://github.com/ljharb [npm-version-png]: http://versionbadg.es/justmoon/node-extend.svg [deps-svg]: https://david-dm.org/justmoon/node-extend.svg [deps-url]: https://david-dm.org/justmoon/node-extend [dev-deps-svg]: https://david-dm.org/justmoon/node-extend/dev-status.svg [dev-deps-url]: https://david-dm.org/justmoon/node-extend#info=devDependencies node-extend-3.0.2/component.json000066400000000000000000000011051332415272500166240ustar00rootroot00000000000000{ "name": "extend", "author": "Stefan Thomas (http://www.justmoon.net)", "version": "3.0.0", "description": "Port of jQuery.extend for node.js and the browser.", "scripts": [ "index.js" ], "contributors": [ { "name": "Jordan Harband", "url": "https://github.com/ljharb" } ], "keywords": [ "extend", "clone", "merge" ], "repository" : { "type": "git", "url": "https://github.com/justmoon/node-extend.git" }, "dependencies": { }, "devDependencies": { "tape" : "~3.0.0", "covert": "~0.4.0", "jscs": "~1.6.2" } } node-extend-3.0.2/index.js000066400000000000000000000063711332415272500154060ustar00rootroot00000000000000'use strict'; var hasOwn = Object.prototype.hasOwnProperty; var toStr = Object.prototype.toString; var defineProperty = Object.defineProperty; var gOPD = Object.getOwnPropertyDescriptor; var isArray = function isArray(arr) { if (typeof Array.isArray === 'function') { return Array.isArray(arr); } return toStr.call(arr) === '[object Array]'; }; var isPlainObject = function isPlainObject(obj) { if (!obj || toStr.call(obj) !== '[object Object]') { return false; } var hasOwnConstructor = hasOwn.call(obj, 'constructor'); var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); // Not own constructor property must be Object if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { return false; } // Own properties are enumerated firstly, so to speed up, // if last one is own, then all properties are own. var key; for (key in obj) { /**/ } return typeof key === 'undefined' || hasOwn.call(obj, key); }; // If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target var setProperty = function setProperty(target, options) { if (defineProperty && options.name === '__proto__') { defineProperty(target, options.name, { enumerable: true, configurable: true, value: options.newValue, writable: true }); } else { target[options.name] = options.newValue; } }; // Return undefined instead of __proto__ if '__proto__' is not an own property var getProperty = function getProperty(obj, name) { if (name === '__proto__') { if (!hasOwn.call(obj, name)) { return void 0; } else if (gOPD) { // In early versions of node, obj['__proto__'] is buggy when obj has // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. return gOPD(obj, name).value; } } return obj[name]; }; module.exports = function extend() { var options, name, src, copy, copyIsArray, clone; var target = arguments[0]; var i = 1; var length = arguments.length; var deep = false; // Handle a deep copy situation if (typeof target === 'boolean') { deep = target; target = arguments[1] || {}; // skip the boolean and the target i = 2; } if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { target = {}; } for (; i < length; ++i) { options = arguments[i]; // Only deal with non-null/undefined values if (options != null) { // Extend the base object for (name in options) { src = getProperty(target, name); copy = getProperty(options, name); // Prevent never-ending loop if (target !== copy) { // Recurse if we're merging plain objects or arrays if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { if (copyIsArray) { copyIsArray = false; clone = src && isArray(src) ? src : []; } else { clone = src && isPlainObject(src) ? src : {}; } // Never move original objects, clone them setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); // Don't bring in undefined values } else if (typeof copy !== 'undefined') { setProperty(target, { name: name, newValue: copy }); } } } } } // Return the modified object return target; }; node-extend-3.0.2/package.json000066400000000000000000000017331332415272500162240ustar00rootroot00000000000000{ "name": "extend", "author": "Stefan Thomas (http://www.justmoon.net)", "version": "3.0.2", "description": "Port of jQuery.extend for node.js and the browser", "main": "index", "scripts": { "pretest": "npm run lint", "test": "npm run tests-only", "posttest": "npm run coverage-quiet", "tests-only": "node test", "coverage": "covert test/index.js", "coverage-quiet": "covert test/index.js --quiet", "lint": "npm run jscs && npm run eslint", "jscs": "jscs *.js */*.js", "eslint": "eslint *.js */*.js" }, "contributors": [ { "name": "Jordan Harband", "url": "https://github.com/ljharb" } ], "keywords": [ "extend", "clone", "merge" ], "repository": { "type": "git", "url": "https://github.com/justmoon/node-extend.git" }, "dependencies": {}, "devDependencies": { "@ljharb/eslint-config": "^12.2.1", "covert": "^1.1.0", "eslint": "^4.19.1", "jscs": "^3.0.7", "tape": "^4.9.1" }, "license": "MIT" } node-extend-3.0.2/test/000077500000000000000000000000001332415272500147115ustar00rootroot00000000000000node-extend-3.0.2/test/.eslintrc000066400000000000000000000001411332415272500165310ustar00rootroot00000000000000{ "rules": { "array-bracket-newline": 0, "array-element-newline": 0, "max-lines": 0, } } node-extend-3.0.2/test/index.js000066400000000000000000000367631332415272500163750ustar00rootroot00000000000000'use strict'; var extend = require('../index'); var test = require('tape'); var str = 'me a test'; var integer = 10; var arr = [1, 'what', new Date(81, 8, 4)]; var date = new Date(81, 4, 13); var Foo = function () {}; var obj = { str: str, integer: integer, arr: arr, date: date, constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }; var deep = { ori: obj, layer: { integer: 10, str: 'str', date: new Date(84, 5, 12), arr: [101, 'dude', new Date(82, 10, 4)], deep: { str: obj.str, integer: integer, arr: obj.arr, date: new Date(81, 7, 4) } } }; test('missing arguments', function (t) { t.deepEqual(extend(undefined, { a: 1 }), { a: 1 }, 'missing first argument is second argument'); t.deepEqual(extend({ a: 1 }), { a: 1 }, 'missing second argument is first argument'); t.deepEqual(extend(true, undefined, { a: 1 }), { a: 1 }, 'deep: missing first argument is second argument'); t.deepEqual(extend(true, { a: 1 }), { a: 1 }, 'deep: missing second argument is first argument'); t.deepEqual(extend(), {}, 'no arguments is object'); t.end(); }); test('merge string with string', function (t) { var ori = 'what u gonna say'; var target = extend(ori, str); var expectedTarget = { 0: 'm', 1: 'e', 2: ' ', 3: 'a', 4: ' ', 5: 't', 6: 'e', 7: 's', 8: 't' }; t.equal(ori, 'what u gonna say', 'original string 1 is unchanged'); t.equal(str, 'me a test', 'original string 2 is unchanged'); t.deepEqual(target, expectedTarget, 'string + string is merged object form of string'); t.end(); }); test('merge string with number', function (t) { var ori = 'what u gonna say'; var target = extend(ori, 10); t.equal(ori, 'what u gonna say', 'original string is unchanged'); t.deepEqual(target, {}, 'string + number is empty object'); t.end(); }); test('merge string with array', function (t) { var ori = 'what u gonna say'; var target = extend(ori, arr); t.equal(ori, 'what u gonna say', 'original string is unchanged'); t.deepEqual(arr, [1, 'what', new Date(81, 8, 4)], 'array is unchanged'); t.deepEqual(target, { 0: 1, 1: 'what', 2: new Date(81, 8, 4) }, 'string + array is array'); t.end(); }); test('merge string with date', function (t) { var ori = 'what u gonna say'; var target = extend(ori, date); var testDate = new Date(81, 4, 13); t.equal(ori, 'what u gonna say', 'original string is unchanged'); t.deepEqual(date, testDate, 'date is unchanged'); t.deepEqual(target, testDate, 'string + date is date'); t.end(); }); test('merge string with obj', function (t) { var ori = 'what u gonna say'; var target = extend(ori, obj); t.equal(ori, 'what u gonna say', 'original string is unchanged'); var testObj = { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }; t.deepEqual(obj, testObj, 'original obj is unchanged'); t.deepEqual(target, testObj, 'string + obj is obj'); t.end(); }); test('merge number with string', function (t) { var ori = 20; var target = extend(ori, str); t.equal(ori, 20, 'number is unchanged'); t.equal(str, 'me a test', 'string is unchanged'); t.deepEqual(target, { 0: 'm', 1: 'e', 2: ' ', 3: 'a', 4: ' ', 5: 't', 6: 'e', 7: 's', 8: 't' }, 'number + string is object form of string'); t.end(); }); test('merge number with number', function (t) { t.deepEqual(extend(20, 10), {}, 'number + number is empty object'); t.end(); }); test('merge number with array', function (t) { var target = extend(20, arr); t.deepEqual(arr, [1, 'what', new Date(81, 8, 4)], 'array is unchanged'); t.deepEqual(target, { 0: 1, 1: 'what', 2: new Date(81, 8, 4) }, 'number + arr is object with array contents'); t.end(); }); test('merge number with date', function (t) { var target = extend(20, date); var testDate = new Date(81, 4, 13); t.deepEqual(date, testDate, 'original date is unchanged'); t.deepEqual(target, testDate, 'number + date is date'); t.end(); }); test('merge number with object', function (t) { var target = extend(20, obj); var testObj = { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }; t.deepEqual(obj, testObj, 'obj is unchanged'); t.deepEqual(target, testObj, 'number + obj is obj'); t.end(); }); test('merge array with string', function (t) { var ori = [1, 2, 3, 4, 5, 6]; var target = extend(ori, str); t.deepEqual(ori, str.split(''), 'array is changed to be an array of string chars'); t.equal(str, 'me a test', 'string is unchanged'); t.deepEqual(target, { 0: 'm', 1: 'e', 2: ' ', 3: 'a', 4: ' ', 5: 't', 6: 'e', 7: 's', 8: 't' }, 'array + string is object form of string'); t.end(); }); test('merge array with number', function (t) { var ori = [1, 2, 3, 4, 5, 6]; var target = extend(ori, 10); t.deepEqual(ori, [1, 2, 3, 4, 5, 6], 'array is unchanged'); t.deepEqual(target, ori, 'array + number is array'); t.end(); }); test('merge array with array', function (t) { var ori = [1, 2, 3, 4, 5, 6]; var target = extend(ori, arr); var testDate = new Date(81, 8, 4); var expectedTarget = [1, 'what', testDate, 4, 5, 6]; t.deepEqual(ori, expectedTarget, 'array + array merges arrays; changes first array'); t.deepEqual(arr, [1, 'what', testDate], 'second array is unchanged'); t.deepEqual(target, expectedTarget, 'array + array is merged array'); t.end(); }); test('merge array with date', function (t) { var ori = [1, 2, 3, 4, 5, 6]; var target = extend(ori, date); var testDate = new Date(81, 4, 13); var testArray = [1, 2, 3, 4, 5, 6]; t.deepEqual(ori, testArray, 'array is unchanged'); t.deepEqual(date, testDate, 'date is unchanged'); t.deepEqual(target, testArray, 'array + date is array'); t.end(); }); test('merge array with object', function (t) { var ori = [1, 2, 3, 4, 5, 6]; var target = extend(ori, obj); var testObject = { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }; t.deepEqual(obj, testObject, 'obj is unchanged'); t.equal(ori.length, 6, 'array has proper length'); t.equal(ori.str, obj.str, 'array has obj.str property'); t.equal(ori.integer, obj.integer, 'array has obj.integer property'); t.deepEqual(ori.arr, obj.arr, 'array has obj.arr property'); t.equal(ori.date, obj.date, 'array has obj.date property'); t.equal(target.length, 6, 'target has proper length'); t.equal(target.str, obj.str, 'target has obj.str property'); t.equal(target.integer, obj.integer, 'target has obj.integer property'); t.deepEqual(target.arr, obj.arr, 'target has obj.arr property'); t.equal(target.date, obj.date, 'target has obj.date property'); t.end(); }); test('merge date with string', function (t) { var ori = new Date(81, 9, 20); var target = extend(ori, str); var testObject = { 0: 'm', 1: 'e', 2: ' ', 3: 'a', 4: ' ', 5: 't', 6: 'e', 7: 's', 8: 't' }; t.deepEqual(ori, testObject, 'date is changed to object form of string'); t.equal(str, 'me a test', 'string is unchanged'); t.deepEqual(target, testObject, 'date + string is object form of string'); t.end(); }); test('merge date with number', function (t) { var ori = new Date(81, 9, 20); var target = extend(ori, 10); t.deepEqual(ori, {}, 'date is changed to empty object'); t.deepEqual(target, {}, 'date + number is empty object'); t.end(); }); test('merge date with array', function (t) { var ori = new Date(81, 9, 20); var target = extend(ori, arr); var testDate = new Date(81, 9, 20); var testArray = [1, 'what', new Date(81, 8, 4)]; t.deepEqual(ori, testDate, 'date is unchanged'); t.deepEqual(arr, testArray, 'array is unchanged'); t.deepEqual(target, testDate, 'date + array is date'); t.end(); }); test('merge date with date', function (t) { var ori = new Date(81, 9, 20); var target = extend(ori, date); t.deepEqual(ori, {}, 'date is empty object'); t.deepEqual(target, {}, 'date + date is empty object'); t.end(); }); test('merge date with object', function (t) { var ori = new Date(81, 9, 20); var target = extend(ori, obj); var testDate = new Date(81, 8, 4); var testObject = { str: 'me a test', integer: 10, arr: [1, 'what', testDate], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }; t.deepEqual(obj, testObject, 'original object is unchanged'); t.deepEqual(ori, testObject, 'date becomes original object'); t.deepEqual(target, testObject, 'date + object is object'); t.end(); }); test('merge object with string', function (t) { var testDate = new Date(81, 7, 26); var ori = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: testDate }; var target = extend(ori, str); var testObj = { 0: 'm', 1: 'e', 2: ' ', 3: 'a', 4: ' ', 5: 't', 6: 'e', 7: 's', 8: 't', str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: testDate }; t.deepEqual(ori, testObj, 'original object updated'); t.equal(str, 'me a test', 'string is unchanged'); t.deepEqual(target, testObj, 'object + string is object + object form of string'); t.end(); }); test('merge object with number', function (t) { var ori = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26) }; var testObject = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26) }; var target = extend(ori, 10); t.deepEqual(ori, testObject, 'object is unchanged'); t.deepEqual(target, testObject, 'object + number is object'); t.end(); }); test('merge object with array', function (t) { var ori = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26) }; var target = extend(ori, arr); var testObject = { 0: 1, 1: 'what', 2: new Date(81, 8, 4), str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26) }; t.deepEqual(ori, testObject, 'original object is merged'); t.deepEqual(arr, [1, 'what', testObject[2]], 'array is unchanged'); t.deepEqual(target, testObject, 'object + array is merged object'); t.end(); }); test('merge object with date', function (t) { var ori = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26) }; var target = extend(ori, date); var testObject = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26) }; t.deepEqual(ori, testObject, 'original object is unchanged'); t.deepEqual(date, new Date(81, 4, 13), 'date is unchanged'); t.deepEqual(target, testObject, 'object + date is object'); t.end(); }); test('merge object with object', function (t) { var ori = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26), foo: 'bar' }; var target = extend(ori, obj); var expectedObj = { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }; var expectedTarget = { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }; t.deepEqual(obj, expectedObj, 'obj is unchanged'); t.deepEqual(ori, expectedTarget, 'original has been merged'); t.deepEqual(target, expectedTarget, 'object + object is merged object'); t.end(); }); test('deep clone', function (t) { var ori = { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26), layer: { deep: { integer: 42 } } }; var target = extend(true, ori, deep); t.deepEqual(ori, { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26), ori: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }, layer: { integer: 10, str: 'str', date: new Date(84, 5, 12), arr: [101, 'dude', new Date(82, 10, 4)], deep: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 7, 4) } } }, 'original object is merged'); t.deepEqual(deep, { ori: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }, layer: { integer: 10, str: 'str', date: new Date(84, 5, 12), arr: [101, 'dude', new Date(82, 10, 4)], deep: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 7, 4) } } }, 'deep is unchanged'); t.deepEqual(target, { str: 'no shit', integer: 76, arr: [1, 2, 3, 4], date: new Date(81, 7, 26), ori: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }, layer: { integer: 10, str: 'str', date: new Date(84, 5, 12), arr: [101, 'dude', new Date(82, 10, 4)], deep: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 7, 4) } } }, 'deep + object + object is deeply merged object'); target.layer.deep = 339; t.deepEqual(deep, { ori: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 4, 13), constructor: 'fake', isPrototypeOf: 'not a function', foo: new Foo() }, layer: { integer: 10, str: 'str', date: new Date(84, 5, 12), arr: [101, 'dude', new Date(82, 10, 4)], deep: { str: 'me a test', integer: 10, arr: [1, 'what', new Date(81, 8, 4)], date: new Date(81, 7, 4) } } }, 'deep is unchanged after setting target property'); // ----- NEVER USE EXTEND WITH THE ABOVE SITUATION ------------------------------ t.end(); }); test('deep clone; arrays are merged', function (t) { var defaults = { arr: [1, 2, 3] }; var override = { arr: ['x'] }; var expectedTarget = { arr: ['x', 2, 3] }; var target = extend(true, defaults, override); t.deepEqual(target, expectedTarget, 'arrays are merged'); t.end(); }); test('deep clone === false; objects merged normally', function (t) { var defaults = { a: 1 }; var override = { a: 2 }; var target = extend(false, defaults, override); t.deepEqual(target, override, 'deep === false handled normally'); t.end(); }); test('pass in null; should create a valid object', function (t) { var override = { a: 1 }; var target = extend(null, override); t.deepEqual(target, override, 'null object handled normally'); t.end(); }); test('works without Array.isArray', function (t) { var savedIsArray = Array.isArray; Array.isArray = false; // don't delete, to preserve enumerability var target = []; var source = [1, [2], { 3: true }]; t.deepEqual( extend(true, target, source), [1, [2], { 3: true }], 'It works without Array.isArray' ); Array.isArray = savedIsArray; t.end(); }); test('non-object target', function (t) { t.deepEqual(extend(3.14, { a: 'b' }), { a: 'b' }); t.deepEqual(extend(true, 3.14, { a: 'b' }), { a: 'b' }); t.end(); }); test('__proto__ is merged as an own property', function (t) { var malicious = { fred: 1 }; Object.defineProperty(malicious, '__proto__', { value: { george: 1 }, enumerable: true }); var target = {}; extend(true, target, malicious); t.notOk(target.george); t.ok(Object.prototype.hasOwnProperty.call(target, '__proto__')); t.deepEqual(Object.getOwnPropertyDescriptor(target, '__proto__').value, { george: 1 }); t.end(); });