lxy dbfac8f913 demo 2 years ago
..
.github 1c63d88d40 demo 2 years ago
test dbfac8f913 demo 2 years ago
.eslintrc 1c63d88d40 demo 2 years ago
.nycrc 1c63d88d40 demo 2 years ago
CHANGELOG.md 1c63d88d40 demo 2 years ago
LICENSE dbfac8f913 demo 2 years ago
README.md dbfac8f913 demo 2 years ago
auto.js dbfac8f913 demo 2 years ago
implementation.js dbfac8f913 demo 2 years ago
index.js dbfac8f913 demo 2 years ago
index.mjs dbfac8f913 demo 2 years ago
package.json dbfac8f913 demo 2 years ago
polyfill.js dbfac8f913 demo 2 years ago
shim.js dbfac8f913 demo 2 years ago

README.md

object.hasown Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES spec-compliant Object.hasOwn shim. Invoke its "shim" method to shim Object.hasOwn if it is unavailable or noncompliant.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Most common usage:

var assert = require('assert');
var hasOwn = require('object.hasown');

var obj = { a: 1, b: 2 };

assert(hasOwn(obj, 'a'));
assert(hasOwn(obj, 'b'));
assert('toString' in obj && !hasOwn(obj, 'toString'));

if (!Object.hasOwn) {
	hasOwn.shim();
}

assert.deepEqual(Object.hasOwn(obj, 'a'), hasOwn(obj, 'a'));

Tests

Simply clone the repo, npm install, and run npm test