Comparing version 1.0.1 to 2.0.0
42
index.js
@@ -1,38 +0,8 @@ | ||
'use strict' | ||
'use strict'; | ||
var hasOwn = Object.prototype.hasOwnProperty | ||
var call = Function.prototype.call; | ||
var $hasOwn = Object.prototype.hasOwnProperty; | ||
var bind = require('function-bind'); | ||
function curry(fn, n){ | ||
if (typeof n !== 'number'){ | ||
n = fn.length | ||
} | ||
function getCurryClosure(prevArgs){ | ||
function curryClosure() { | ||
var len = arguments.length | ||
var args = [].concat(prevArgs) | ||
if (len){ | ||
args.push.apply(args, arguments) | ||
} | ||
if (args.length < n){ | ||
return getCurryClosure(args) | ||
} | ||
return fn.apply(this, args) | ||
} | ||
return curryClosure | ||
} | ||
return getCurryClosure([]) | ||
} | ||
module.exports = curry(function(object, property){ | ||
return hasOwn.call(object, property) | ||
}) | ||
/** @type {(o: {}, p: PropertyKey) => p is keyof o} */ | ||
module.exports = bind.call(call, $hasOwn); |
119
package.json
{ | ||
"name": "hasown", | ||
"version": "1.0.1", | ||
"description": "JavaScript curried hasOwn helper", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "make test", | ||
"test-w": "make test-w", | ||
"test-debug": "mocha --debug-brk" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.21.0", | ||
"should": "~4.0.4" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/radubrehar/hasown.git" | ||
}, | ||
"keywords": [ | ||
"own", | ||
"property", | ||
"hasOwn", | ||
"properties", | ||
"object", | ||
"key" | ||
], | ||
"author": "Radu Brehar", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/radubrehar/has-own/issues" | ||
} | ||
"name": "hasown", | ||
"version": "2.0.0", | ||
"description": "A robust, ES3 compatible, \"has own property\" predicate.", | ||
"main": "index.js", | ||
"exports": { | ||
".": "./index.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"prepack": "npmignore --auto --commentLines=autogenerated && npm run emit-types", | ||
"prepublish": "not-in-publish || npm run prepublishOnly", | ||
"prepublishOnly": "safe-publish-latest", | ||
"prelint": "evalmd README.md", | ||
"lint": "eslint --ext=js,mjs .", | ||
"postlint": "npm run tsc", | ||
"preemit-types": "rm -f *.ts *.ts.map test/*.ts test/*.ts.map", | ||
"emit-types": "npm run tsc -- --noEmit false --emitDeclarationOnly", | ||
"pretest": "npm run lint", | ||
"tsc": "tsc -p .", | ||
"tests-only": "nyc tape 'test/**/*.js'", | ||
"test": "npm run tests-only", | ||
"posttest": "aud --production", | ||
"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": "git+https://github.com/inspect-js/hasOwn.git" | ||
}, | ||
"keywords": [ | ||
"has", | ||
"hasOwnProperty", | ||
"hasOwn", | ||
"has-own", | ||
"own", | ||
"has", | ||
"property", | ||
"in", | ||
"javascript", | ||
"ecmascript" | ||
], | ||
"author": "Jordan Harband <ljharb@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/inspect-js/hasOwn/issues" | ||
}, | ||
"homepage": "https://github.com/inspect-js/hasOwn#readme", | ||
"dependencies": { | ||
"function-bind": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^21.1.0", | ||
"@types/function-bind": "^1.1.9", | ||
"@types/mock-property": "^1.0.1", | ||
"@types/tape": "^5.6.3", | ||
"aud": "^2.0.3", | ||
"auto-changelog": "^2.4.0", | ||
"eslint": "=8.8.0", | ||
"evalmd": "^0.0.19", | ||
"in-publish": "^2.0.1", | ||
"mock-property": "^1.0.2", | ||
"npmignore": "^0.3.0", | ||
"nyc": "^10.3.2", | ||
"safe-publish-latest": "^2.0.0", | ||
"tape": "^5.7.1", | ||
"typescript": "^5.3.0-dev.20231019" | ||
}, | ||
"engines": { | ||
"node": ">= 0.4" | ||
}, | ||
"testling": { | ||
"files": "test/index.js" | ||
}, | ||
"auto-changelog": { | ||
"output": "CHANGELOG.md", | ||
"template": "keepachangelog", | ||
"unreleased": false, | ||
"commitLimit": false, | ||
"backfillLimit": false, | ||
"hideCredit": true | ||
}, | ||
"publishConfig": { | ||
"ignore": [ | ||
".github/workflows", | ||
"test", | ||
"!*.d.ts", | ||
"!*.d.ts.map" | ||
] | ||
} | ||
} |
@@ -1,55 +0,40 @@ | ||
hasown | ||
======= | ||
# hasown <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
JavaScript curried hasOwn helper. | ||
[![github actions][actions-image]][actions-url] | ||
[![coverage][codecov-image]][codecov-url] | ||
[![License][license-image]][license-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
## Install | ||
[![npm badge][npm-badge-png]][package-url] | ||
```sh | ||
$ npm install hasown | ||
``` | ||
A robust, ES3 compatible, "has own property" predicate. | ||
## Usage | ||
## Example | ||
#### Simple usage | ||
```js | ||
var hasOwn = require('hasown') | ||
var person = { name: 'bob' } | ||
const assert = require('assert'); | ||
const hasOwn = require('hasown'); | ||
hasOwn(person, 'name') == true | ||
assert.equal(hasOwn({}, 'toString'), false); | ||
assert.equal(hasOwn([], 'length'), true); | ||
assert.equal(hasOwn({ a: 42 }, 'a'), true); | ||
``` | ||
#### Curried usage | ||
## Tests | ||
Simply clone the repo, `npm install`, and run `npm test` | ||
```js | ||
var hasOwn = require('hasown') | ||
var person = { lastName: 'willson' } | ||
var child = Object.create(person) | ||
child.age = 1 | ||
child.firstName = 'bob' | ||
var childHasOwn = hasOwn(child) | ||
for (var k in child) if (childHasOwn(k)){ | ||
console.log(k, ' = ', child[k]) | ||
} | ||
``` | ||
## Test | ||
```sh | ||
$ make | ||
``` | ||
Watch mode | ||
```sh | ||
$ make test-w | ||
``` | ||
## License | ||
``` | ||
MIT | ||
``` | ||
[package-url]: https://npmjs.org/package/hasown | ||
[npm-version-svg]: https://versionbadg.es/inspect-js/hasown.svg | ||
[deps-svg]: https://david-dm.org/inspect-js/hasOwn.svg | ||
[deps-url]: https://david-dm.org/inspect-js/hasOwn | ||
[dev-deps-svg]: https://david-dm.org/inspect-js/hasOwn/dev-status.svg | ||
[dev-deps-url]: https://david-dm.org/inspect-js/hasOwn#info=devDependencies | ||
[npm-badge-png]: https://nodei.co/npm/hasown.png?downloads=true&stars=true | ||
[license-image]: https://img.shields.io/npm/l/hasown.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: https://img.shields.io/npm/dm/hasown.svg | ||
[downloads-url]: https://npm-stat.com/charts.html?package=hasown | ||
[codecov-image]: https://codecov.io/gh/inspect-js/hasOwn/branch/main/graphs/badge.svg | ||
[codecov-url]: https://app.codecov.io/gh/inspect-js/hasOwn/ | ||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/hasOwn | ||
[actions-url]: https://github.com/inspect-js/hasOwn/actions |
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 bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
11
0
0
10837
1
15
49
41
2
+ Addedfunction-bind@^1.1.2
+ Addedfunction-bind@1.1.2(transitive)