reflect.ownkeys
Advanced tools
Comparing version 0.2.0 to 1.0.0
28
index.js
@@ -1,11 +0,17 @@ | ||
if (typeof Reflect === 'object' && typeof Reflect.ownKeys === 'function') { | ||
module.exports = Reflect.ownKeys; | ||
} else if (typeof Object.getOwnPropertySymbols === 'function') { | ||
module.exports = function Reflect_ownKeys(o) { | ||
return ( | ||
Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o)) | ||
); | ||
} | ||
} else { | ||
module.exports = Object.getOwnPropertyNames; | ||
} | ||
'use strict'; | ||
var define = require('define-properties'); | ||
var implementation = require('./implementation'); | ||
var getPolyfill = require('./polyfill'); | ||
var shim = require('./shim'); | ||
var polyfill = getPolyfill(); | ||
define(polyfill, { | ||
getPolyfill: getPolyfill, | ||
implementation: implementation, | ||
shim: shim | ||
}); | ||
module.exports = polyfill; |
121
package.json
{ | ||
"name": "reflect.ownkeys", | ||
"version": "0.2.0", | ||
"description": "Polyfill for ES6's Reflect.ownKeys", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/glenjamin/Reflect.ownKeys.git" | ||
}, | ||
"keywords": [ | ||
"es6", | ||
"reflect", | ||
"ownkeys", | ||
"polyfill" | ||
], | ||
"author": "Glen Mailer <glen@stainlessed.co.uk>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/glenjamin/Reflect.ownKeys/issues" | ||
}, | ||
"homepage": "https://github.com/glenjamin/Reflect.ownKeys", | ||
"devDependencies": { | ||
"mocha": "^2.4.5" | ||
} | ||
"name": "reflect.ownkeys", | ||
"version": "1.0.0", | ||
"description": "ES2015 spec-compliant shim for Reflect.ownKeys", | ||
"main": "index.js", | ||
"exports": { | ||
".": [ | ||
{ | ||
"default": "./index.js" | ||
}, | ||
"./index.js" | ||
], | ||
"./auto": [ | ||
{ | ||
"default": "./auto.js" | ||
}, | ||
"./auto.js" | ||
], | ||
"./shim": [ | ||
{ | ||
"default": "./shim.js" | ||
}, | ||
"./shim.js" | ||
], | ||
"./polyfill": [ | ||
{ | ||
"default": "./polyfill.js" | ||
}, | ||
"./polyfill.js" | ||
], | ||
"./implementation": [ | ||
{ | ||
"default": "./implementation.js" | ||
}, | ||
"./implementation.js" | ||
], | ||
"./package": "./package.json", | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"prepublish": "safe-publish-latest", | ||
"lint": "eslint .", | ||
"postlint": "es-shim-api --bound", | ||
"pretest": "npm run lint", | ||
"tests-only": "node test", | ||
"test": "npm run tests-only", | ||
"posttest": "npx aud", | ||
"version": "auto-changelog && git add CHANGELOG.md", | ||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/es-shims/Reflect.ownKeys.git" | ||
}, | ||
"keywords": [ | ||
"es6", | ||
"es2015", | ||
"reflect", | ||
"ownkeys", | ||
"polyfill", | ||
"shim", | ||
"es-shim API" | ||
], | ||
"author": "Jordan Harband <ljharb@gmail.com>", | ||
"contributors": [ | ||
"Glen Mailer <glen@stainlessed.co.uk>" | ||
], | ||
"funding": { | ||
"url": "https://github.com/sponsors/ljharb" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/es-shims/Reflect.ownKeys/issues" | ||
}, | ||
"homepage": "https://github.com/es-shims/Reflect.ownKeys", | ||
"devDependencies": { | ||
"@es-shims/api": "^2.1.2", | ||
"@ljharb/eslint-config": "^15.1.0", | ||
"auto-changelog": "^1.16.2", | ||
"eslint": "^6.8.0", | ||
"has-symbols": "^1.0.1", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.0.0-next.3" | ||
}, | ||
"auto-changelog": { | ||
"output": "CHANGELOG.md", | ||
"template": "keepachangelog", | ||
"unreleased": false, | ||
"commitLimit": false, | ||
"backfillLimit": false | ||
}, | ||
"dependencies": { | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.17.2", | ||
"globalthis": "^1.0.1" | ||
} | ||
} |
@@ -1,17 +0,55 @@ | ||
# Reflect.ownKeys | ||
# reflect.ownkeys <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
Polyfill for ES6's [Reflect.ownKeys](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys) | ||
[![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] | ||
## Installing | ||
[![npm badge][npm-badge-png]][package-url] | ||
```sh | ||
npm install reflect.ownkeys | ||
``` | ||
An ES2015 spec-compliant `Reflect.ownKeys` shim. Invoke its "shim" method to shim `Reflect.ownKeys` if it is unavailable or noncompliant. | ||
## Example | ||
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](https://tc39.es/ecma262/#sec-reflect.ownkeys). | ||
Most common usage: | ||
```js | ||
var assert = require('assert'); | ||
var ownKeys = require('reflect.ownkeys'); | ||
ownKeys({a: 1, b: 2}); | ||
// => [ "a", "b" ] | ||
var obj = { a: 1, b: 2, c: 3 }; | ||
var expected = ['a', 'b', 'c']; | ||
if (typeof Symbol === 'function' && typeof Symbol() === 'symbol') { | ||
// for environments with Symbol support | ||
var sym = Symbol(); | ||
obj[sym] = 4; | ||
obj.d = sym; | ||
expected.push(sym, 'd'); | ||
} | ||
assert.deepEqual(ownKeys(obj), expected); | ||
if (!Reflect.ownKeys) { | ||
ownKeys.shim(); | ||
} | ||
assert.deepEqual(Reflect.ownKeys(obj), expected); | ||
``` | ||
## Tests | ||
Simply clone the repo, `npm install`, and run `npm test` | ||
[package-url]: https://npmjs.com/package/reflect.ownkeys | ||
[npm-version-svg]: http://versionbadg.es/es-shims/Reflect.ownKeys.svg | ||
[travis-svg]: https://travis-ci.org/es-shims/Reflect.ownKeys.svg | ||
[travis-url]: https://travis-ci.org/es-shims/Reflect.ownKeys | ||
[deps-svg]: https://david-dm.org/es-shims/Reflect.ownKeys.svg | ||
[deps-url]: https://david-dm.org/es-shims/Reflect.ownKeys | ||
[dev-deps-svg]: https://david-dm.org/es-shims/Reflect.ownKeys/dev-status.svg | ||
[dev-deps-url]: https://david-dm.org/es-shims/Reflect.ownKeys#info=devDependencies | ||
[npm-badge-png]: https://nodei.co/npm/reflect.ownkeys.png?downloads=true&stars=true | ||
[license-image]: http://img.shields.io/npm/l/reflect.ownkeys.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: http://img.shields.io/npm/dm/reflect.ownkeys.svg | ||
[downloads-url]: http://npm-stat.com/charts.html?package=reflect.ownkeys |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11714
13
97
0
56
3
7
2
+ Addeddefine-properties@^1.1.3
+ Addedes-abstract@^1.17.2
+ Addedglobalthis@^1.0.1
+ Addedarray-buffer-byte-length@1.0.1(transitive)
+ Addedarraybuffer.prototype.slice@1.0.3(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addeddata-view-buffer@1.0.1(transitive)
+ Addeddata-view-byte-length@1.0.1(transitive)
+ Addeddata-view-byte-offset@1.0.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-abstract@1.23.3(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedes-set-tostringtag@2.0.3(transitive)
+ Addedes-to-primitive@1.2.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunction.prototype.name@1.1.6(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-symbol-description@1.0.2(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-bigints@1.0.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinternal-slot@1.0.7(transitive)
+ Addedis-array-buffer@3.0.4(transitive)
+ Addedis-bigint@1.0.4(transitive)
+ Addedis-boolean-object@1.1.2(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.1(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-negative-zero@2.0.3(transitive)
+ Addedis-number-object@1.0.7(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedis-shared-array-buffer@1.0.3(transitive)
+ Addedis-string@1.0.7(transitive)
+ Addedis-symbol@1.0.4(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedis-weakref@1.0.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedregexp.prototype.flags@1.5.3(transitive)
+ Addedsafe-array-concat@1.1.2(transitive)
+ Addedsafe-regex-test@1.0.3(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstring.prototype.trim@1.2.9(transitive)
+ Addedstring.prototype.trimend@1.0.8(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedtyped-array-buffer@1.0.2(transitive)
+ Addedtyped-array-byte-length@1.0.1(transitive)
+ Addedtyped-array-byte-offset@1.0.2(transitive)
+ Addedtyped-array-length@1.0.6(transitive)
+ Addedunbox-primitive@1.0.2(transitive)
+ Addedwhich-boxed-primitive@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)