{"id":27610370,"url":"https://github.com/openinf/openinf-util-object","last_synced_at":"2025-04-22T23:27:04.203Z","repository":{"id":38123330,"uuid":"330311113","full_name":"OpenINF/openinf-util-object","owner":"OpenINF","description":"Common JavaScript object type-related utilities","archived":false,"fork":false,"pushed_at":"2025-04-21T19:36:46.000Z","size":540,"stargazers_count":3,"open_issues_count":31,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-21T20:40:31.963Z","etag":null,"topics":["commonjs","commonjs-module","commonjs-package","functional","helpers","helpers-library","javascript","javascript-library","nodejs","nodejs-module","npm","npm-package","object","predicate","type","typescript","typescript-library","typescript-package","utilities"],"latest_commit_sha":null,"homepage":"https://github.com/OpenINF/openinf-util-object#readme","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenINF.png","metadata":{"funding":{"github":[]},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-17T04:06:55.000Z","updated_at":"2024-05-24T16:14:38.000Z","dependencies_parsed_at":"2023-10-30T21:31:06.566Z","dependency_job_id":"53862d11-35bc-4be3-8fc3-b83400c5b4e5","html_url":"https://github.com/OpenINF/openinf-util-object","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-util-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenINF","download_url":"https://codeload.github.com/OpenINF/openinf-util-object/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250339330,"owners_count":21414340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commonjs","commonjs-module","commonjs-package","functional","helpers","helpers-library","javascript","javascript-library","nodejs","nodejs-module","npm","npm-package","object","predicate","type","typescript","typescript-library","typescript-package","utilities"],"created_at":"2025-04-22T23:27:03.545Z","updated_at":"2025-04-22T23:27:04.181Z","avatar_url":"https://github.com/OpenINF.png","language":"JavaScript","readme":"\u003ca href=\"https://open.inf.is\"\u003e\n  \u003cimg\n    src=\"https://open.inf.is/assets/img/svg/logogram-color.svg\"\n    alt=\"OpenINF logo\"\n    title=\"OpenINF\"\n    align=\"right\"\n    height=\"96\"\n    width=\"96\"\n  /\u003e\n\u003c/a\u003e\n\n\u003cdiv align=\"left\"\u003e\n\n## `@openinf/util-object`\n\n\u003e Common JavaScript object type-related utilities\n\n\u003cbr /\u003e\n\n[!['View on npm'][npm-badge--shields]][npm-badge-url]\n[!['License: MIT/Apache-2.0'][license-badge--shields]][license-badge-url]\n\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\nThe high-level goal of `@openinf/util-object` is to serve as a Node.js package\ncontaining utilities for **common JavaScript object type-related operations**\nprimarily enabling users to perform comparisons and analyze object contents. We\nare constantly working to improve this repository, so please feel free to\n[contribute](#contributing) if you notice any omissions or errors.\n\nThanks!\n\n\u003cbr /\u003e\n\n\u003cdetails id=\"platform--node-js-lts\"\u003e\n\t\u003csummary\u003e\n\t\t\u003ca\n\t\t\thref=\"#platform--node-js-lts\"\n\t\t\ttitle=\"Platform: Node.js LTS\"\n\t\t\u003e\n\t\t\t\u003cimg\n\t\t\t\tsrc=\"https://img.shields.io/badge/Node.js-LTS-black?logo=Node.js\u0026logoColor=lightgreen\u0026color=2a2a2a\u0026labelColor=black\"\n\t\t\t\talt=\"Platform: Node.js LTS\"\n\t\t\t/\u003e\n\t\t\u003c/a\u003e\n\t\u003c/summary\u003e\n\t\u003cdiv align=\"left\"\u003e\u003cbr /\u003e\n\t\t\u003ca\n\t\t\ttarget=\"_blank\"\n\t\t\ttitle=\"Node.js release schedule\"\n\t\t\thref=\"https://github.com/nodejs/release#release-schedule\"\n\t\t\u003e\n\t\t\t\u003cstrong\u003eSupported Node.js Environments\u003c/strong\u003e\n\t\t\u003c/a\u003e\u003cbr /\u003e\u003cbr /\u003e\n\n- [ ] v4：Argon (Ar)\n- [ ] v6：Boron (B)\n- [ ] v8：Carbon (C)\n- [ ] v10：Dubnium (Db)\n- [ ] v12：Erbium (Er)\n- [x] v14：Fermium (Fm)\n- [x] v16：Gallium (Ga)\n- [x] v18：Hydrogen (H)\n\u003c!-- TODO\n- [x] v20: Iron (Fe) --\u003e\n\n\u003c/div\u003e\u003c/details\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Code Style: Prettier][prettier-badge]][prettier-url]\n[![Commit Style: Conventional Commits][conventional-commits-badge]][conventional-commits-url]\n[![Chat on Matrix][matrix-badge--shields]][matrix-url]\n\n\u003c/div\u003e\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n### Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\t\u003c!-- markdownlint-disable-next-line line-length --\u003e\n\t\u003ch3 id=\"installation\" align=\"left\"\u003eInstallation \u003ca href=\"##\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/nodejs/corepack/main/icon.svg?sanitize=true\" alt=\"Corepack logo\" title=\"Corepack friendly\" align=\"right\" height=\"24\" width=\"24\" /\u003e\u003c/a\u003e\u003c/h3\u003e\n\u003c/summary\u003e\n\n\u003cbr /\u003e\n\n`@openinf/util-object` runs on\n[supported versions of Node.js](#platform--node-js-lts) and is available via\n**`npm`**, **`pnpm`**, or **`yarn`**.\n\n**Using the npm CLI**\n\n\u003csup\u003eSee the\n[official documentation for this command](https://docs.npmjs.com/cli/commands/npm-install)\nfor more information.\u003c/sup\u003e\n\n```shell\nnpm i @openinf/util-object\n```\n\n**Using the pnpm CLI**\n\n\u003csup\u003eSee the [official documentation for this command](https://pnpm.io/cli/add)\nfor more information.\u003c/sup\u003e\n\n```shell\npnpm add @openinf/util-object\n```\n\n**Using the Yarn 1 CLI (Classic)**\n\n\u003csup\u003eSee the\n[official documentation for this command](https://classic.yarnpkg.com/en/docs/cli/add)\nfor more information.\u003c/sup\u003e\n\n```shell\nyarn add @openinf/util-object\n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n### Usage\n\n```ts\nimport { hasOwn } from '@openinf/util-object';\n\nexport class GhFileImporter {\n  constructor(options: GhFileImporterOptions) {\n    if (!hasOwn(options, 'destDir')) {\n      throw new MissingOptionError('destDir');\n    }\n  }\n}\n```\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n\u003cdetails open=\"\"\u003e\n\t\u003csummary\u003e\u003ch3\u003eAPI\u003c/h3\u003e\u003c/summary\u003e\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#map\"\u003emap([opt_initial])\u003c/a\u003e ⇒ \u003ccode\u003eT\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns a map-like object. If \u003ccode\u003eopt_initial\u003c/code\u003e is provided, copies its own\nproperties into the newly created object.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#hasOwn\"\u003ehasOwn(obj, key)\u003c/a\u003e ⇒ \u003ccode\u003eboolean\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eChecks if the given key is a property in the map.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#ownProperty\"\u003eownProperty(obj, key)\u003c/a\u003e ⇒ \u003ccode\u003eunknown\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eReturns obj[key] iff key is obj\u0026#39;s own property (is not inherited).\nOtherwise, returns undefined.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#deepMerge\"\u003edeepMerge(target, source, depth)\u003c/a\u003e ⇒ \u003ccode\u003eObject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eDeep merges source into target.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#omit\"\u003eomit(o, props)\u003c/a\u003e ⇒ \u003ccode\u003eRecord\u0026lt;string, (number|RegExp)\u0026gt;\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#objectsEqualShallow\"\u003eobjectsEqualShallow(o1, o2)\u003c/a\u003e ⇒ \u003ccode\u003eboolean\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#memo\"\u003ememo(obj, prop, factory)\u003c/a\u003e ⇒ \u003ccode\u003eR\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eTakes an object, a property name, and a factory function. If the value of\nthe property is undefined, it generates a value with the factory function,\nupdates the object originally passed, and returns the value that was returned\nby the factory function.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"map\"\u003e\u003c/a\u003e\n\n#### map([opt_initial]) ⇒ \u003ccode\u003eT\u003c/code\u003e\n\nReturns a map-like object. If `opt_initial` is provided, copies its own\nproperties into the newly created object.\n\n**Kind**: global function\n\n| Param         | Type           | Description                                 |\n| ------------- | -------------- | ------------------------------------------- |\n| [opt_initial] | \u003ccode\u003eT\u003c/code\u003e | This should typically be an object literal. |\n\n\u003ca name=\"hasOwn\"\u003e\u003c/a\u003e\n\n#### hasOwn(obj, key) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n\nChecks if the given key is a property in the map.\n\n**Kind**: global function\n\n| Param | Type                | Description          |\n| ----- | ------------------- | -------------------- |\n| obj   | \u003ccode\u003eT\u003c/code\u003e      | a map like property. |\n| key   | \u003ccode\u003estring\u003c/code\u003e |                      |\n\n\u003ca name=\"ownProperty\"\u003e\u003c/a\u003e\n\n#### ownProperty(obj, key) ⇒ \u003ccode\u003eunknown\u003c/code\u003e\n\nReturns obj[key] iff key is obj's own property (is not inherited). Otherwise,\nreturns undefined.\n\n**Kind**: global function\n\n| Param | Type                                                 |\n| ----- | ---------------------------------------------------- |\n| obj   | \u003ccode\u003eRecord\u0026lt;string, (number\\|RegExp)\u0026gt;\u003c/code\u003e |\n| key   | \u003ccode\u003estring\u003c/code\u003e                                  |\n\n\u003ca name=\"deepMerge\"\u003e\u003c/a\u003e\n\n#### deepMerge(target, source, depth) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\nDeep merges source into target.\n\n**Kind**: global function  \n**Throws**:\n\n- \u003ccode\u003eError\u003c/code\u003e If source contains a circular reference. Note: Only nested\n  objects are deep-merged, primitives and arrays are not.\n\n| Param  | Type                | Default         | Description                                                               |\n| ------ | ------------------- | --------------- | ------------------------------------------------------------------------- |\n| target | \u003ccode\u003eObject\u003c/code\u003e |                 |                                                                           |\n| source | \u003ccode\u003eObject\u003c/code\u003e |                 |                                                                           |\n| depth  | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e10\u003c/code\u003e | The maximum merge depth. If exceeded, Object.assign will be used instead. |\n\n\u003ca name=\"deepMerge..queue\"\u003e\u003c/a\u003e\n\n##### deepMerge~queue : \u003ccode\u003eArray\u0026lt;ITargetSourceDepth\u0026gt;\u003c/code\u003e\n\n**Kind**: inner constant of [\u003ccode\u003edeepMerge\u003c/code\u003e](#deepMerge)  \n\u003ca name=\"omit\"\u003e\u003c/a\u003e\n\n#### omit(o, props) ⇒ \u003ccode\u003eRecord\u0026lt;string, (number\\|RegExp)\u0026gt;\u003c/code\u003e\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003eRecord\u0026lt;string, (number\\|RegExp)\u0026gt;\u003c/code\u003e - An object\nwith the given properties removed.\n\n| Param | Type                                                 | Description                                     |\n| ----- | ---------------------------------------------------- | ----------------------------------------------- |\n| o     | \u003ccode\u003eRecord\u0026lt;string, (number\\|RegExp)\u0026gt;\u003c/code\u003e | An object to remove properties from.            |\n| props | \u003ccode\u003eArray\u0026lt;string\u0026gt;\u003c/code\u003e                    | A list of properties to remove from the Object. |\n\n\u003ca name=\"objectsEqualShallow\"\u003e\u003c/a\u003e\n\n#### objectsEqualShallow(o1, o2) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n\n**Kind**: global function\n\n| Param | Type                                                                                                 |\n| ----- | ---------------------------------------------------------------------------------------------------- |\n| o1    | \u003ccode\u003e!Record\u0026lt;string, (number\\|RegExp)\u0026gt;\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e \\| \u003ccode\u003eundefined\u003c/code\u003e |\n| o2    | \u003ccode\u003e!Record\u0026lt;string, (number\\|RegExp)\u0026gt;\u003c/code\u003e \\| \u003ccode\u003enull\u003c/code\u003e \\| \u003ccode\u003eundefined\u003c/code\u003e |\n\n\u003ca name=\"memo\"\u003e\u003c/a\u003e\n\n#### memo(obj, prop, factory) ⇒ \u003ccode\u003eR\u003c/code\u003e\n\nTakes an object, a property name, and a factory function. If the value of the\nproperty is undefined, it generates a value with the factory function, updates\nthe object originally passed, and returns the value that was returned by the\nfactory function.\n\n**Kind**: global function\n\n| Param   | Type                  |\n| ------- | --------------------- |\n| obj     | \u003ccode\u003eT\u003c/code\u003e        |\n| prop    | \u003ccode\u003estring\u003c/code\u003e   |\n| factory | \u003ccode\u003efunction\u003c/code\u003e |\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n\u003c/details\u003e\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n### Contributing\n\nPull requests are welcome. For major changes, please open an issue first to\ndiscuss what you would like to change. If for whatever reason you spot something\nto fix but cannot patch it yourself, please [open an issue][].\n\n\u003cbr /\u003e\n\n### License\n\nThis project is licensed under either of\n\n- [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n- [MIT license](https://opensource.org/licenses/MIT)\n\nat your option.\n\nThe [SPDX](https://spdx.dev) license identifier for this project is\n`MIT OR Apache-2.0`.\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n### Show Your Support\n\n\u003cbr /\u003e\n\nIf you like the project (or want to bookmark it)\u0026nbsp;\u0026mdash;\u003cbr /\u003e\n\u0026mdash;\u0026nbsp;[give it a star ⭐️][]\u0026nbsp;\u0026mdash;\u0026nbsp;it will greatly encourage\nus.\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n\u003ca title=\"The OpenINF website\" href=\"https://open.inf.is\" rel=\"author\"\u003e\n  \u003cimg alt=\"The OpenINF logo\" height=\"32px\" width=\"32px\" src=\"https://open.inf.is/assets/img/svg/logogram-color.svg\" /\u003e\n\u003c/a\u003e\n\n\u003c/div\u003e\n\n\u003c!-- BEGIN LINK DEFINITIONS --\u003e\n[conventional-commits-badge]: https://img.shields.io/badge/commit%20style-Conventional-%23fa6673?logoColor=white\u0026logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMCAzMCI+PHBhdGggc3R5bGU9ImZpbGw6ICNGRkYiIGQ9Ik0xNSwyQTEzLDEzLDAsMSwxLDIsMTUsMTMsMTMsMCwwLDEsMTUsMm0wLTJBMTUsMTUsMCwxLDAsMzAsMTUsMTUsMTUsMCwwLDAsMTUsMFoiLz48L3N2Zz4K 'Commit Style: Conventional Commits'\n[conventional-commits-url]: https://www.conventionalcommits.org 'Commit Style: Conventional Commits'\n[give it a star ⭐️]: https://github.com/OpenINF/openinf-util-object/stargazers\n[license-badge--shields]: https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg?logo=github 'License: MIT/Apache 2.0'\n[license-badge-url]: #license 'License: MIT/Apache 2.0'\n[matrix-badge--shields]: https://img.shields.io/badge/matrix-join%20chat-%2346BC99?logo=matrix 'Chat on Matrix'\n[matrix-url]: https://matrix.to/#/#openinf-space:matrix.org 'You\u0026apos;re invited to talk on Matrix'\n[npm-badge--shields]: https://img.shields.io/npm/v/@openinf/util-object/latest.svg?logo=npm\u0026color=fe7d37 'View on npm'\n[npm-badge-url]: https://www.npmjs.com/package/@openinf/util-object#top 'View on npm'\n[open an issue]: https://github.com/OpenINF/openinf-util-object/issues\n[prettier-badge]: https://img.shields.io/badge/code_style-Prettier-ff69b4.svg?logo=prettier 'Code Style: Prettier'\n[prettier-url]: https://prettier.io/playground 'Code Style: Prettier'\n[project-status-badge]: https://img.shields.io/badge/project%20status-under%20construction-orange 'Project Status: Under construction badge'\n\u003c!-- END LINK DEFINITIONS --\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopeninf%2Fopeninf-util-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopeninf%2Fopeninf-util-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopeninf%2Fopeninf-util-object/lists"}