Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

es-object-atoms

ljharb95.9mMIT1.1.1TypeScript support: included

ES Object-related atoms: Object, ToObject, RequireObjectCoercible

javascript, ecmascript, object, toobject, coercible

readme

es-object-atoms Version Badge

github actions coverage License Downloads

npm badge

ES Object-related atoms: Object, ToObject, RequireObjectCoercible.

Example

const assert = require('assert');

const $Object = require('es-object-atoms');
const isObject = require('es-object-atoms/isObject');
const ToObject = require('es-object-atoms/ToObject');
const RequireObjectCoercible = require('es-object-atoms/RequireObjectCoercible');

assert.equal($Object, Object);
assert.throws(() => ToObject(null), TypeError);
assert.throws(() => ToObject(undefined), TypeError);
assert.throws(() => RequireObjectCoercible(null), TypeError);
assert.throws(() => RequireObjectCoercible(undefined), TypeError);

assert.equal(isObject(undefined), false);
assert.equal(isObject(null), false);
assert.equal(isObject({}), true);
assert.equal(isObject([]), true);
assert.equal(isObject(function () {}), true);

assert.deepEqual(RequireObjectCoercible(true), true);
assert.deepEqual(ToObject(true), Object(true));

const obj = {};
assert.equal(RequireObjectCoercible(obj), obj);
assert.equal(ToObject(obj), obj);

Tests

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

Security

Please email @ljharb or see https://tidelift.com/security if you have a potential security vulnerability to report.

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.1 - 2025-01-14

Commits

  • [types] ToObject: improve types cfe8c8a

v1.1.0 - 2025-01-14

Commits

v1.0.1 - 2025-01-13

Commits

  • [Dev Deps] update @ljharb/eslint-config, @ljharb/tsconfig, @types/tape, auto-changelog, tape 38ab9eb
  • [types] improve types 7d1beb8
  • [Tests] replace aud with npm audit 25863ba
  • [Dev Deps] add missing peer dep c012309

v1.0.0 - 2024-03-16

Commits