Gathering detailed insights and metrics for class-utils
Gathering detailed insights and metrics for class-utils
Gathering detailed insights and metrics for class-utils
Gathering detailed insights and metrics for class-utils
@stdlib/utils-native-class
Determine the specification defined classification of an object.
@stdlib/utils-constructor-name
Determine the name of a value's constructor.
@erudilabs/merge-class-utils
Utility function to efficiently merge Tailwind CSS classes in JS without style conflicts.
error-class-utils
Properly create error classes
Utils for working with JavaScript classes and prototype methods.
npm install class-utils
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99
Supply Chain
95.2
Quality
77
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
4,408,688,960
Last Day
1,877,849
Last Week
11,453,616
Last Month
45,783,179
Last Year
550,902,772
MIT License
19 Stars
50 Commits
7 Forks
3 Watchers
1 Branches
4 Contributors
Updated on Dec 28, 2023
Minified
Minified + Gzipped
Latest Version
0.3.6
Package Id
class-utils@0.3.6
Size
5.25 kB
NPM Version
5.6.0
Node Version
9.1.0
Published on
Jan 11, 2018
Cumulative downloads
Total Downloads
Last Day
23.3%
1,877,849
Compared to previous day
Last Week
15.7%
11,453,616
Compared to previous week
Last Month
5.1%
45,783,179
Compared to previous month
Last Year
-21%
550,902,772
Compared to previous year
4
Utils for working with JavaScript classes and prototype methods.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
1$ npm install --save class-utils
1var cu = require('class-utils');
Returns true if an array has any of the given elements, or an object has any of the give keys.
Params
obj
{Object}val
{String|Array}returns
{Boolean}Example
1cu.has(['a', 'b', 'c'], 'c'); 2//=> true 3 4cu.has(['a', 'b', 'c'], ['c', 'z']); 5//=> true 6 7cu.has({a: 'b', c: 'd'}, ['c', 'z']); 8//=> true
Returns true if an array or object has all of the given values.
Params
val
{Object|Array}values
{String|Array}returns
{Boolean}Example
1cu.hasAll(['a', 'b', 'c'], 'c'); 2//=> true 3 4cu.hasAll(['a', 'b', 'c'], ['c', 'z']); 5//=> false 6 7cu.hasAll({a: 'b', c: 'd'}, ['c', 'z']); 8//=> false
Cast the given value to an array.
Params
val
{String|Array}returns
{Array}Example
1cu.arrayify('foo'); 2//=> ['foo'] 3 4cu.arrayify(['foo']); 5//=> ['foo']
Returns true if a value has a contructor
Params
value
{Object}returns
{Boolean}Example
1cu.hasConstructor({}); 2//=> true 3 4cu.hasConstructor(Object.create(null)); 5//=> false
Get the native ownPropertyNames
from the constructor of the given object
. An empty array is returned if the object does not have a constructor.
Params
obj
{Object}: Object that has a constructor
.returns
{Array}: Array of keys.Example
1cu.nativeKeys({a: 'b', b: 'c', c: 'd'}) 2//=> ['a', 'b', 'c'] 3 4cu.nativeKeys(function(){}) 5//=> ['length', 'caller']
Returns property descriptor key
if it's an "own" property of the given object.
Params
obj
{Object}key
{String}returns
{Object}: Returns descriptor key
Example
1function App() {}
2Object.defineProperty(App.prototype, 'count', {
3 get: function() {
4 return Object.keys(this).length;
5 }
6});
7cu.getDescriptor(App.prototype, 'count');
8// returns:
9// {
10// get: [Function],
11// set: undefined,
12// enumerable: false,
13// configurable: false
14// }
Copy a descriptor from one object to another.
Params
receiver
{Object}provider
{Object}name
{String}returns
{Object}Example
1function App() {}
2Object.defineProperty(App.prototype, 'count', {
3 get: function() {
4 return Object.keys(this).length;
5 }
6});
7var obj = {};
8cu.copyDescriptor(obj, App.prototype, 'count');
Copy static properties, prototype properties, and descriptors from one object to another.
Params
receiver
{Object}provider
{Object}omit
{String|Array}: One or more properties to omitreturns
{Object}Inherit the static properties, prototype properties, and descriptors from of an object.
Params
receiver
{Object}provider
{Object}omit
{String|Array}: One or more properties to omitreturns
{Object}Returns a function for extending the static properties, prototype properties, and descriptors from the Parent
constructor onto Child
constructors.
Params
Parent
{Function}: Parent ctorextend
{Function}: Optional extend function to handle custom extensions. Useful when updating methods that require a specific prototype.Child
{Function}: Child ctorproto
{Object}: Optionally pass additional prototype properties to inherit.returns
{Object}Example
1var extend = cu.extend(Parent); 2Parent.extend(Child); 3 4// optional methods 5Parent.extend(Child, { 6 foo: function() {}, 7 bar: function() {} 8});
Bubble up events emitted from static methods on the Parent ctor.
Params
Parent
{Object}events
{Array}: Event names to bubble upPull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running 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:
1$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
1$ npm install -g verbose/verb#dev verb-generate-readme && verb
You might also be interested in these projects:
Commits | Contributor |
---|---|
34 | jonschlinkert |
8 | doowb |
2 | wtgtybhertgeghgtwtg |
Jon Schlinkert
Copyright © 2018, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on January 11, 2018.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-21
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More