{"id":15661264,"url":"https://github.com/jonschlinkert/class-utils","last_synced_at":"2025-04-13T09:37:39.635Z","repository":{"id":55551030,"uuid":"42545882","full_name":"jonschlinkert/class-utils","owner":"jonschlinkert","description":"Utils for working with JavaScript classes and prototype methods.","archived":false,"fork":false,"pushed_at":"2023-03-14T09:15:33.000Z","size":42,"stargazers_count":19,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T01:09:42.347Z","etag":null,"topics":["class","descriptor","javascript","object","prototype-methods","prototype-property","utility"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-15T20:52:24.000Z","updated_at":"2023-12-28T04:27:51.000Z","dependencies_parsed_at":"2024-06-18T13:52:53.837Z","dependency_job_id":"0a36499e-eec4-4a74-baa9-715a555f25cd","html_url":"https://github.com/jonschlinkert/class-utils","commit_stats":{"total_commits":47,"total_committers":4,"mean_commits":11.75,"dds":"0.21276595744680848","last_synced_commit":"af95c76f0317c13c494fb5054a78bb974210cfeb"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fclass-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fclass-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fclass-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fclass-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/class-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248602302,"owners_count":21131615,"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":["class","descriptor","javascript","object","prototype-methods","prototype-property","utility"],"created_at":"2024-10-03T13:26:44.424Z","updated_at":"2025-04-13T09:37:39.606Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# class-utils [![NPM version](https://img.shields.io/npm/v/class-utils.svg?style=flat)](https://www.npmjs.com/package/class-utils) [![NPM monthly downloads](https://img.shields.io/npm/dm/class-utils.svg?style=flat)](https://npmjs.org/package/class-utils) [![NPM total downloads](https://img.shields.io/npm/dt/class-utils.svg?style=flat)](https://npmjs.org/package/class-utils) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/class-utils.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/class-utils)\n\n\u003e Utils for working with JavaScript classes and prototype methods.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save class-utils\n```\n\n## Usage\n\n```js\nvar cu = require('class-utils');\n```\n\n## API\n\n### [.has](index.js#L43)\n\nReturns true if an array has any of the given elements, or an object has any of the give keys.\n\n**Params**\n\n* `obj` **{Object}**\n* `val` **{String|Array}**\n* `returns` **{Boolean}**\n\n**Example**\n\n```js\ncu.has(['a', 'b', 'c'], 'c');\n//=\u003e true\n\ncu.has(['a', 'b', 'c'], ['c', 'z']);\n//=\u003e true\n\ncu.has({a: 'b', c: 'd'}, ['c', 'z']);\n//=\u003e true\n```\n\n### [.hasAll](index.js#L90)\n\nReturns true if an array or object has all of the given values.\n\n**Params**\n\n* `val` **{Object|Array}**\n* `values` **{String|Array}**\n* `returns` **{Boolean}**\n\n**Example**\n\n```js\ncu.hasAll(['a', 'b', 'c'], 'c');\n//=\u003e true\n\ncu.hasAll(['a', 'b', 'c'], ['c', 'z']);\n//=\u003e false\n\ncu.hasAll({a: 'b', c: 'd'}, ['c', 'z']);\n//=\u003e false\n```\n\n### [.arrayify](index.js#L117)\n\nCast the given value to an array.\n\n**Params**\n\n* `val` **{String|Array}**\n* `returns` **{Array}**\n\n**Example**\n\n```js\ncu.arrayify('foo');\n//=\u003e ['foo']\n\ncu.arrayify(['foo']);\n//=\u003e ['foo']\n```\n\n### [.hasConstructor](index.js#L152)\n\nReturns true if a value has a `contructor`\n\n**Params**\n\n* `value` **{Object}**\n* `returns` **{Boolean}**\n\n**Example**\n\n```js\ncu.hasConstructor({});\n//=\u003e true\n\ncu.hasConstructor(Object.create(null));\n//=\u003e false\n```\n\n### [.nativeKeys](index.js#L174)\n\nGet the native `ownPropertyNames` from the constructor of the given `object`. An empty array is returned if the object does not have a constructor.\n\n**Params**\n\n* `obj` **{Object}**: Object that has a `constructor`.\n* `returns` **{Array}**: Array of keys.\n\n**Example**\n\n```js\ncu.nativeKeys({a: 'b', b: 'c', c: 'd'})\n//=\u003e ['a', 'b', 'c']\n\ncu.nativeKeys(function(){})\n//=\u003e ['length', 'caller']\n```\n\n### [.getDescriptor](index.js#L208)\n\nReturns property descriptor `key` if it's an \"own\" property of the given object.\n\n**Params**\n\n* `obj` **{Object}**\n* `key` **{String}**\n* `returns` **{Object}**: Returns descriptor `key`\n\n**Example**\n\n```js\nfunction App() {}\nObject.defineProperty(App.prototype, 'count', {\n  get: function() {\n    return Object.keys(this).length;\n  }\n});\ncu.getDescriptor(App.prototype, 'count');\n// returns:\n// {\n//   get: [Function],\n//   set: undefined,\n//   enumerable: false,\n//   configurable: false\n// }\n```\n\n### [.copyDescriptor](index.js#L238)\n\nCopy a descriptor from one object to another.\n\n**Params**\n\n* `receiver` **{Object}**\n* `provider` **{Object}**\n* `name` **{String}**\n* `returns` **{Object}**\n\n**Example**\n\n```js\nfunction App() {}\nObject.defineProperty(App.prototype, 'count', {\n  get: function() {\n    return Object.keys(this).length;\n  }\n});\nvar obj = {};\ncu.copyDescriptor(obj, App.prototype, 'count');\n```\n\n### [.copy](index.js#L264)\n\nCopy static properties, prototype properties, and descriptors\nfrom one object to another.\n\n**Params**\n\n* `receiver` **{Object}**\n* `provider` **{Object}**\n* `omit` **{String|Array}**: One or more properties to omit\n* `returns` **{Object}**\n\n### [.inherit](index.js#L299)\n\nInherit the static properties, prototype properties, and descriptors\nfrom of an object.\n\n**Params**\n\n* `receiver` **{Object}**\n* `provider` **{Object}**\n* `omit` **{String|Array}**: One or more properties to omit\n* `returns` **{Object}**\n\n### [.extend](index.js#L343)\n\nReturns a function for extending the static properties, prototype properties, and descriptors from the `Parent` constructor onto `Child` constructors.\n\n**Params**\n\n* `Parent` **{Function}**: Parent ctor\n* `extend` **{Function}**: Optional extend function to handle custom extensions. Useful when updating methods that require a specific prototype.\n* `Child` **{Function}**: Child ctor\n* `proto` **{Object}**: Optionally pass additional prototype properties to inherit.\n* `returns` **{Object}**\n\n**Example**\n\n```js\nvar extend = cu.extend(Parent);\nParent.extend(Child);\n\n// optional methods\nParent.extend(Child, {\n  foo: function() {},\n  bar: function() {}\n});\n```\n\n### [.bubble](index.js#L356)\n\nBubble up events emitted from static methods on the Parent ctor.\n\n**Params**\n\n* `Parent` **{Object}**\n* `events` **{Array}**: Event names to bubble up\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [define-property](https://www.npmjs.com/package/define-property): Define a non-enumerable property on an object. Uses Reflect.defineProperty when available, otherwise Object.defineProperty. | [homepage](https://github.com/jonschlinkert/define-property \"Define a non-enumerable property on an object. Uses Reflect.defineProperty when available, otherwise Object.defineProperty.\")\n* [delegate-properties](https://www.npmjs.com/package/delegate-properties): Deep-clone properties from one object to another and make them non-enumerable, or make existing properties… [more](https://github.com/jonschlinkert/delegate-properties) | [homepage](https://github.com/jonschlinkert/delegate-properties \"Deep-clone properties from one object to another and make them non-enumerable, or make existing properties on an object non-enumerable.\")\n* [is-descriptor](https://www.npmjs.com/package/is-descriptor): Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… [more](https://github.com/jonschlinkert/is-descriptor) | [homepage](https://github.com/jonschlinkert/is-descriptor \"Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.\")\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 34 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 8 | [doowb](https://github.com/doowb) |\n| 2 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |\n\n### Author\n\n**Jon Schlinkert**\n\n* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on January 11, 2018._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fclass-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fclass-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fclass-utils/lists"}