Package detail

object.hasown

es-shims34.8mMIT1.1.4

ES spec-compliant shim for Object.hasOwn

Object, hasOwn, polyfill, shim

readme

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.1.4 - 2024-03-22

Commits

  • [meta] remove useless ESM 28440a5
  • [actions] remove redundant finisher 579b54d
  • [Deps] update es-abstract f7f9aa1
  • [Dev Deps] update call-bind, npmignore, tape 8a2f213
  • [Refactor] use es-object-atoms instead of es-abstract f0efe3b
  • [Dev Deps] update call-bind, tape 683b500
  • [Deps] update define-properties, es-abstract f74ecf2
  • [meta] add missing engines.node 7ca6eeb
  • [Deps] update es-abstract d5aa232
  • [Dev Deps] update aud 26fa7f9

v1.1.3 - 2023-08-28

Commits

  • [Deps] update define-properties, es-abstract 4ca792b
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, tape ce37aaa

v1.1.2 - 2022-11-06

Commits

  • [actions] update rebase action to use reusable workflow db8c17c
  • [Deps] update es-abstract 8b549d2
  • [Dev Deps] update @ljharb/eslint-config, aud, tape 25fc539

v1.1.1 - 2022-05-05

Commits

  • [actions] remove unused actions 4ca5814
  • [actions] reuse common workflows e265a2f
  • [meta] use npmignore to autogenerate an npmignore file 4f54d5e
  • [Fix] shim: properly install when already present f580b50
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, functions-have-names, has-symbols, tape 335d3c1
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, safe-publish-latest, tape c040e94
  • [actions] update codecov uploader 723dd15
  • [Deps] update define-properties, es-abstract 4fb99f9
  • [Dev Deps] update @ljharb/eslint-config 9a5e992

v1.1.0 - 2021-10-03

Commits

  • [New] add ESM entry point 8b8b4b2
  • [Tests] add implementation tests 5edecfe
  • [Deps] update es-abstract 6ebc660
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, tape e1832e2
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog b1adc25
  • [Deps] update es-abstract 1e7a06c
  • [Deps] update es-abstract 622d71c

v1.0.0 - 2021-05-25

Commits