mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 05:14:44 +00:00
.
This commit is contained in:
parent
00c3b50fca
commit
ae5dcb46c8
7331 changed files with 1784502 additions and 0 deletions
13
node_modules/define-properties/.editorconfig
generated
vendored
Normal file
13
node_modules/define-properties/.editorconfig
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab;
|
||||
insert_final_newline = true;
|
||||
quote_type = auto;
|
||||
space_after_anonymous_functions = true;
|
||||
space_after_control_statements = true;
|
||||
spaces_around_operators = true;
|
||||
trim_trailing_whitespace = true;
|
||||
spaces_in_brackets = false;
|
||||
end_of_line = lf;
|
||||
|
12
node_modules/define-properties/.eslintrc
generated
vendored
Normal file
12
node_modules/define-properties/.eslintrc
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"id-length": [2, { "min": 1, "max": 35 }],
|
||||
"max-lines-per-function": [2, 100],
|
||||
"max-params": [2, 4],
|
||||
"max-statements": [2, 13]
|
||||
}
|
||||
}
|
175
node_modules/define-properties/.jscs.json
generated
vendored
Normal file
175
node_modules/define-properties/.jscs.json
generated
vendored
Normal file
|
@ -0,0 +1,175 @@
|
|||
{
|
||||
"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": 3
|
||||
},
|
||||
|
||||
"requirePaddingNewLinesAfterUseStrict": true,
|
||||
|
||||
"disallowArrowFunctions": true,
|
||||
|
||||
"disallowMultiLineTernary": true,
|
||||
|
||||
"validateOrderInObjectKeys": "asc-insensitive",
|
||||
|
||||
"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
|
||||
}
|
||||
|
233
node_modules/define-properties/.travis.yml
generated
vendored
Normal file
233
node_modules/define-properties/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,233 @@
|
|||
language: node_js
|
||||
os:
|
||||
- linux
|
||||
node_js:
|
||||
- "10.8"
|
||||
- "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.7"
|
||||
env: TEST=true ALLOW_FAILURE=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
|
||||
- env: COVERAGE=true
|
44
node_modules/define-properties/CHANGELOG.md
generated
vendored
Normal file
44
node_modules/define-properties/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
1.1.3 / 2018-08-14
|
||||
=================
|
||||
* [Refactor] use a for loop instead of `foreach` to make for smaller bundle sizes
|
||||
* [Robustness] cache `Array.prototype.concat` and `Object.defineProperty`
|
||||
* [Deps] update `object-keys`
|
||||
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `nsp`, `tape`, `jscs`; remove unused eccheck script + dep
|
||||
* [Tests] use pretest/posttest for linting/security
|
||||
* [Tests] fix npm upgrades on older nodes
|
||||
|
||||
1.1.2 / 2015-10-14
|
||||
=================
|
||||
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG
|
||||
* [Deps] Update `object-keys`
|
||||
* [Dev Deps] update `jscs`, `tape`, `eslint`, `@ljharb/eslint-config`, `nsp`
|
||||
* [Tests] up to `io.js` `v3.3`, `node` `v4.2`
|
||||
|
||||
1.1.1 / 2015-07-21
|
||||
=================
|
||||
* [Deps] Update `object-keys`
|
||||
* [Dev Deps] Update `tape`, `eslint`
|
||||
* [Tests] Test on `io.js` `v2.4`
|
||||
|
||||
1.1.0 / 2015-07-01
|
||||
=================
|
||||
* [New] Add support for symbol-valued properties.
|
||||
* [Dev Deps] Update `nsp`, `eslint`
|
||||
* [Tests] Test up to `io.js` `v2.3`
|
||||
|
||||
1.0.3 / 2015-05-30
|
||||
=================
|
||||
* Using a more reliable check for supported property descriptors.
|
||||
|
||||
1.0.2 / 2015-05-23
|
||||
=================
|
||||
* Test up to `io.js` `v2.0`
|
||||
* Update `tape`, `jscs`, `nsp`, `eslint`, `object-keys`, `editorconfig-tools`, `covert`
|
||||
|
||||
1.0.1 / 2015-01-06
|
||||
=================
|
||||
* Update `object-keys` to fix ES3 support
|
||||
|
||||
1.0.0 / 2015-01-04
|
||||
=================
|
||||
* v1.0.0
|
21
node_modules/define-properties/LICENSE
generated
vendored
Normal file
21
node_modules/define-properties/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2015 Jordan Harband
|
||||
|
||||
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.
|
86
node_modules/define-properties/README.md
generated
vendored
Normal file
86
node_modules/define-properties/README.md
generated
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
#define-properties <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
||||
|
||||
[![Build Status][travis-svg]][travis-url]
|
||||
[![dependency status][deps-svg]][deps-url]
|
||||
[![dev dependency status][dev-deps-svg]][dev-deps-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][npm-badge-png]][package-url]
|
||||
|
||||
[![browser support][testling-svg]][testling-url]
|
||||
|
||||
Define multiple non-enumerable properties at once. Uses `Object.defineProperty` when available; falls back to standard assignment in older engines.
|
||||
Existing properties are not overridden. Accepts a map of property names to a predicate that, when true, force-overrides.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var define = require('define-properties');
|
||||
var assert = require('assert');
|
||||
|
||||
var obj = define({ a: 1, b: 2 }, {
|
||||
a: 10,
|
||||
b: 20,
|
||||
c: 30
|
||||
});
|
||||
assert(obj.a === 1);
|
||||
assert(obj.b === 2);
|
||||
assert(obj.c === 30);
|
||||
if (define.supportsDescriptors) {
|
||||
assert.deepEqual(Object.keys(obj), ['a', 'b']);
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'c'), {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: 30,
|
||||
writable: false
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
Then, with predicates:
|
||||
```js
|
||||
var define = require('define-properties');
|
||||
var assert = require('assert');
|
||||
|
||||
var obj = define({ a: 1, b: 2, c: 3 }, {
|
||||
a: 10,
|
||||
b: 20,
|
||||
c: 30
|
||||
}, {
|
||||
a: function () { return false; },
|
||||
b: function () { return true; }
|
||||
});
|
||||
assert(obj.a === 1);
|
||||
assert(obj.b === 20);
|
||||
assert(obj.c === 3);
|
||||
if (define.supportsDescriptors) {
|
||||
assert.deepEqual(Object.keys(obj), ['a', 'c']);
|
||||
assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'b'), {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: 20,
|
||||
writable: false
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
## Tests
|
||||
Simply clone the repo, `npm install`, and run `npm test`
|
||||
|
||||
[package-url]: https://npmjs.org/package/define-properties
|
||||
[npm-version-svg]: http://versionbadg.es/ljharb/define-properties.svg
|
||||
[travis-svg]: https://travis-ci.org/ljharb/define-properties.svg
|
||||
[travis-url]: https://travis-ci.org/ljharb/define-properties
|
||||
[deps-svg]: https://david-dm.org/ljharb/define-properties.svg
|
||||
[deps-url]: https://david-dm.org/ljharb/define-properties
|
||||
[dev-deps-svg]: https://david-dm.org/ljharb/define-properties/dev-status.svg
|
||||
[dev-deps-url]: https://david-dm.org/ljharb/define-properties#info=devDependencies
|
||||
[testling-svg]: https://ci.testling.com/ljharb/define-properties.png
|
||||
[testling-url]: https://ci.testling.com/ljharb/define-properties
|
||||
[npm-badge-png]: https://nodei.co/npm/define-properties.png?downloads=true&stars=true
|
||||
[license-image]: http://img.shields.io/npm/l/define-properties.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: http://img.shields.io/npm/dm/define-properties.svg
|
||||
[downloads-url]: http://npm-stat.com/charts.html?package=define-properties
|
||||
|
58
node_modules/define-properties/index.js
generated
vendored
Normal file
58
node_modules/define-properties/index.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
'use strict';
|
||||
|
||||
var keys = require('object-keys');
|
||||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
|
||||
|
||||
var toStr = Object.prototype.toString;
|
||||
var concat = Array.prototype.concat;
|
||||
var origDefineProperty = Object.defineProperty;
|
||||
|
||||
var isFunction = function (fn) {
|
||||
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
|
||||
};
|
||||
|
||||
var arePropertyDescriptorsSupported = function () {
|
||||
var obj = {};
|
||||
try {
|
||||
origDefineProperty(obj, 'x', { enumerable: false, value: obj });
|
||||
// eslint-disable-next-line no-unused-vars, no-restricted-syntax
|
||||
for (var _ in obj) { // jscs:ignore disallowUnusedVariables
|
||||
return false;
|
||||
}
|
||||
return obj.x === obj;
|
||||
} catch (e) { /* this is IE 8. */
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
|
||||
|
||||
var defineProperty = function (object, name, value, predicate) {
|
||||
if (name in object && (!isFunction(predicate) || !predicate())) {
|
||||
return;
|
||||
}
|
||||
if (supportsDescriptors) {
|
||||
origDefineProperty(object, name, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: value,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
object[name] = value;
|
||||
}
|
||||
};
|
||||
|
||||
var defineProperties = function (object, map) {
|
||||
var predicates = arguments.length > 2 ? arguments[2] : {};
|
||||
var props = keys(map);
|
||||
if (hasSymbols) {
|
||||
props = concat.call(props, Object.getOwnPropertySymbols(map));
|
||||
}
|
||||
for (var i = 0; i < props.length; i += 1) {
|
||||
defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
|
||||
}
|
||||
};
|
||||
|
||||
defineProperties.supportsDescriptors = !!supportsDescriptors;
|
||||
|
||||
module.exports = defineProperties;
|
69
node_modules/define-properties/package.json
generated
vendored
Normal file
69
node_modules/define-properties/package.json
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"name": "define-properties",
|
||||
"version": "1.1.3",
|
||||
"author": "Jordan Harband",
|
||||
"description": "Define multiple non-enumerable properties at once. Uses `Object.defineProperty` when available; falls back to standard assignment in older engines.",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"pretest": "npm run --silent lint",
|
||||
"test": "npm run --silent tests-only",
|
||||
"posttest": "npm run --silent security",
|
||||
"tests-only": "node test/index.js",
|
||||
"coverage": "covert test/*.js",
|
||||
"coverage-quiet": "covert test/*.js --quiet",
|
||||
"lint": "npm run --silent jscs && npm run --silent eslint",
|
||||
"jscs": "jscs test/*.js *.js",
|
||||
"eslint": "eslint test/*.js *.js",
|
||||
"security": "nsp check"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/ljharb/define-properties.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Object.defineProperty",
|
||||
"Object.defineProperties",
|
||||
"object",
|
||||
"property descriptor",
|
||||
"descriptor",
|
||||
"define",
|
||||
"ES5"
|
||||
],
|
||||
"dependencies": {
|
||||
"object-keys": "^1.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^13.0.0",
|
||||
"covert": "^1.1.0",
|
||||
"eslint": "^5.3.0",
|
||||
"jscs": "^3.0.7",
|
||||
"nsp": "^3.2.1",
|
||||
"tape": "^4.9.0"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/index.js",
|
||||
"browsers": [
|
||||
"iexplore/6.0..latest",
|
||||
"firefox/3.0..6.0",
|
||||
"firefox/15.0..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/4.0..10.0",
|
||||
"chrome/20.0..latest",
|
||||
"chrome/canary",
|
||||
"opera/10.0..latest",
|
||||
"opera/next",
|
||||
"safari/4.0..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz"
|
||||
,"_integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ=="
|
||||
,"_from": "define-properties@1.1.3"
|
||||
}
|
125
node_modules/define-properties/test/index.js
generated
vendored
Normal file
125
node_modules/define-properties/test/index.js
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
'use strict';
|
||||
|
||||
var define = require('../');
|
||||
var test = require('tape');
|
||||
var keys = require('object-keys');
|
||||
|
||||
var arePropertyDescriptorsSupported = function () {
|
||||
var obj = { a: 1 };
|
||||
try {
|
||||
Object.defineProperty(obj, 'x', { value: obj });
|
||||
return obj.x === obj;
|
||||
} catch (e) { /* this is IE 8. */
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var descriptorsSupported = !!Object.defineProperty && arePropertyDescriptorsSupported();
|
||||
|
||||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
|
||||
|
||||
test('defineProperties', function (dt) {
|
||||
dt.test('with descriptor support', { skip: !descriptorsSupported }, function (t) {
|
||||
var getDescriptor = function (value) {
|
||||
return {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: value,
|
||||
writable: true
|
||||
};
|
||||
};
|
||||
|
||||
var obj = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
};
|
||||
t.deepEqual(keys(obj), ['a', 'b', 'c'], 'all literal-set keys start enumerable');
|
||||
define(obj, {
|
||||
b: 3,
|
||||
c: 4,
|
||||
d: 5
|
||||
});
|
||||
t.deepEqual(obj, {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
}, 'existing properties were not overridden');
|
||||
t.deepEqual(Object.getOwnPropertyDescriptor(obj, 'd'), getDescriptor(5), 'new property "d" was added and is not enumerable');
|
||||
t.deepEqual(['a', 'b', 'c'], keys(obj), 'new keys are not enumerable');
|
||||
|
||||
define(obj, {
|
||||
a: 2,
|
||||
b: 3,
|
||||
c: 4
|
||||
}, {
|
||||
a: function () { return true; },
|
||||
b: function () { return false; }
|
||||
});
|
||||
t.deepEqual(obj, {
|
||||
b: 2,
|
||||
c: 3
|
||||
}, 'properties only overriden when predicate exists and returns true');
|
||||
t.deepEqual(Object.getOwnPropertyDescriptor(obj, 'd'), getDescriptor(5), 'existing property "d" remained and is not enumerable');
|
||||
t.deepEqual(Object.getOwnPropertyDescriptor(obj, 'a'), getDescriptor(2), 'existing property "a" was overridden and is not enumerable');
|
||||
t.deepEqual(['b', 'c'], keys(obj), 'overridden keys are not enumerable');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
dt.test('without descriptor support', { skip: descriptorsSupported }, function (t) {
|
||||
var obj = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
};
|
||||
define(obj, {
|
||||
b: 3,
|
||||
c: 4,
|
||||
d: 5
|
||||
});
|
||||
t.deepEqual(obj, {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
d: 5
|
||||
}, 'existing properties were not overridden, new properties were added');
|
||||
|
||||
define(obj, {
|
||||
a: 2,
|
||||
b: 3,
|
||||
c: 4
|
||||
}, {
|
||||
a: function () { return true; },
|
||||
b: function () { return false; }
|
||||
});
|
||||
t.deepEqual(obj, {
|
||||
a: 2,
|
||||
b: 2,
|
||||
c: 3,
|
||||
d: 5
|
||||
}, 'properties only overriden when predicate exists and returns true');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
dt.end();
|
||||
});
|
||||
|
||||
test('symbols', { skip: !hasSymbols }, function (t) {
|
||||
var sym = Symbol('foo');
|
||||
var obj = {};
|
||||
var aValue = {};
|
||||
var bValue = {};
|
||||
var properties = { a: aValue };
|
||||
properties[sym] = bValue;
|
||||
|
||||
define(obj, properties);
|
||||
|
||||
t.deepEqual(Object.keys(obj), [], 'object has no enumerable keys');
|
||||
t.deepEqual(Object.getOwnPropertyNames(obj), ['a'], 'object has non-enumerable "a" key');
|
||||
t.deepEqual(Object.getOwnPropertySymbols(obj), [sym], 'object has non-enumerable symbol key');
|
||||
t.equal(obj.a, aValue, 'string keyed value is defined');
|
||||
t.equal(obj[sym], bValue, 'symbol keyed value is defined');
|
||||
|
||||
t.end();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue