npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

craydent-object

v1.0.2

Published

Node module to extend all native class functionality and simplify code for maintainability and readability

Downloads

63

Readme

Craydent 1.0.2

by Clark Inada

Craydent is all inclusive utility library. There are several ways to use the library in NodeJS. More detailed documentation on constants can be found at Craydent Properties. More detailed documentation on methods can be found at Craydent Methods

// require with prototypes - this require will add prototypes to extend classes and add two constants ($c, $g) to the global space.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-object');
$c.logit($c.VERSION);
arr.prototypedMethod(args);
// require no conflict - this require is the fully modular version with no global constants, prototypes, or methods.
var $c = require('craydent-object/noConflict');
$c.logit($c.VERSION);
$c.prototypedMethod(arr, args);
// require global - this require constants and methods in the global space and add prototypes to extend classes.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent-object/global');
logit($c.VERSION);
arr.prototypedMethod(args);

Categories

Constants

| | | | | ----- | ----- | ----- | | CONSOLE_COLORS (Object) |LOCAL_IP (String) |TEMPLATE_TAG_CONFIG (Object) | DEBUG_MODE (Boolean) |MODULES_LOADED (Object) |TEMPLATE_VARS (Array) | ERROR_TYPES (Array) |PUBLIC_IP (String) |VERSION (String) | HTTP_STATUS_TEMPLATE (Object) |RESPONSES (Object) |

Featured

Object


get


Info: Alias to getProperty; however, it can not be used as a protoype property.

Return: (any)

Parameters:

  • object: (Object) object to get the property of
  • path: (String) Path to nested property
  • delimiter?: (Char) Separator used to parse path

Overloads:

Parameters

  • object: (Object) object to get the property of
  • path: (RegExp) Regex match for the property

Parameters

  • object: (Object) object to get the property of
  • path: (String) Path to nested property
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

Parameters

  • object: (Object) object to get the property of
  • path: (String) Path to nested property
  • delimiter: (Char) Separator used to parse path
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

getProperty


Info: Object class extension to retrieve nested properties without error when property path does not exist

Return: (any)

Parameters:

  • path: (String) Path to nested property

Overloads:

Parameters

  • path: (String) Path to nested property
  • delimiter: (Char) Separator used to parse path

Parameters

  • path: (RegExp) Regex match for the property

Parameters

  • path: (String) Path to nested property
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

Parameters

  • path: (String) Path to nested property
  • delimiter: (Char) Separator used to parse path
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

Methods

Object


addObjectPrototype


Info: Method to extend the Object Class

Return: (void)

Parameters:

  • name: (String) name of the method to add
  • fn: (Function) method implementation
  • override?: (Bool) if true, override the previously defined prototype

Overloads:

None


changes


Info: Object class extension to compare properties that have changed

Return: (Object)

Parameters:

  • compare: (any) Object to compare against

Overloads:

None


contains


Info: Object class extension to check if value exists

Return: (Bool)

Parameters:

  • val: (ContainsValue|ContainsObjectIterator<T, TValue>) Value to check or custom function to determine validity

Overloads:

Parameters

  • val: (ContainsValue) Value to check
  • func: (ContainsIterator) Callback function used to do the comparison

Parameters

  • val: (ContainsValue) Value to check
  • func: (ComparisonOperator) String indicating logical operator ("$lt"|"$lte"|"$gt"|"$gte"|"$mod"|"$type")

Parameters

  • arr: (Array) Array of values to return first matching value

copyObject


Info: Object class extension to copy an object excluding constructor

Return: (Object)

Parameters:

None

Overloads:

None


count


Info: Object class extension to count the properties in the object/elements in arrays/characters in strings.

Return: (Int)

Parameters:

None

Overloads:

Parameters

  • option: (WhereCondition) Query used in Array.where when counting elements in an Array

Parameters

  • option: (String) Word or phrase to count in the String

Parameters

  • option: (RegExp) Word or phrase pattern to count in the String

duplicate


Info: Object class extension to copy an object including constructor

Return: (Object)

Parameters:

  • recursive?: (Boolean) Flag to copy all child objects recursively

Overloads:

None


eachProperty


Info: Object class extension to loop through all properties where hasOwnValue is true.

Return: (Object)

Parameters:

  • callback: (EachIterator) Function to call for each property. Callback will have two arguments (the value of the object and the property name) passed

Overloads:

None


every


Info: Object class extension to check property values against a function

Return: (Bool)

Parameters:

  • callback: (ObjectIterator<T, TValue>) Callback to apply to each value

Overloads:

Parameters

  • callback: (ObjectIterator<T, TValue>) Callback to apply to each value
  • craydent_ctxObject: (any) Context for the callback function

equals


Info: Object class extension to check if object values are equal

Return: (Bool)

Parameters:

  • compare: (any) Object to compare against
  • props?: (String[]) Array of property values to compare against

Overloads:

None


getClass


Info: Object class extension to get the constructor name

Return: (String)

Parameters:

None

Overloads:

None


getKeys


Info: Object class extension to get the keys of the object

Return: (Array)

Parameters:

None

Overloads:

None


has


Info: Alias to Object.prototype.hasOwnProperty

Return: (Boolean)

Parameters:

  • property: (String) Property name to check

Overloads:

None


isArray


Info: Object class extension to check if object is an array

Return: (Bool)

Parameters:

None

Overloads:

None


isAsync


Info: Object class extension to check if object is a async function

Return: (Bool)

Parameters:

None

Overloads:

None


isBetween


Info: Object class extension to check if object is between lower and upper bounds

Return: (Bool)

Parameters:

  • lowerBound: (any) Lower bound comparison
  • upperBound: (any) Upper bound comparison
  • inclusive?: (Bool) Flag to include give bounds

Overloads:

None


isBoolean


Info: Object class extension to check if object is a boolean

Return: (Bool)

Parameters:

None

Overloads:

None


isDate


Info: Object class extension to check if object is a date

Return: (Bool)

Parameters:

None

Overloads:

None


isDomElement


Info: Object class extension to check if object is a DOM element

Return: (Bool)

Parameters:

None

Overloads:

None


isEmpty


Info: Object class extension to check if it is empty

Return: (Bool)

Parameters:

None

Overloads:

None


isError


Info: Object class extension to check if object is an error object

Return: (Bool)

Parameters:

None

Overloads:

None


isFloat


Info: Object class extension to check if object is a float

Return: (Bool)

Parameters:

None

Overloads:

None


isFunction


Info: Object class extension to check if object is a function

Return: (Bool)

Parameters:

None

Overloads:

None


isGenerator


Info: Object class extension to check if object is a generator function

Return: (Bool)

Parameters:

None

Overloads:

None


isGeolocation


Info: Object class extension to check if object is a geolocation

Return: (Bool)

Parameters:

None

Overloads:

None


isInt


Info: Object class extension to check if object is an integer

Return: (Bool)

Parameters:

None

Overloads:

None


isNullOrEmpty


Info: Object class extension to check if object is a null or empty (object with no props, empty string, etc)

Return: (Bool)

Parameters:

None

Overloads:

None


isNumber


Info: Object class extension to check if object is a number

Return: (Bool)

Parameters:

None

Overloads:

None


isObject


Info: Object class extension to check if object is an object

Return: (Bool)

Parameters:

None

Overloads:

None


isPromise


Info: Object class extension to check if object is a promise object

Return: (Bool)

Parameters:

None

Overloads:

None


isRegExp


Info: Object class extension to check if object is a RegExp

Return: (Bool)

Parameters:

None

Overloads:

None


isString


Info: Object class extension to check if object is a string

Return: (Bool)

Parameters:

None

Overloads:

None


isSubset


Info: Object class extension to check if item is a subset

Return: (Bool)

Parameters:

  • compare: (any) Superset to compare against
  • sharesAny: (Boolean) Flag to check if any property is shared

Overloads:

None


itemCount


Info: Object class extension to count the properties in item

Return: (Int)

Parameters:

None

Overloads:

None


keyOf


Info: Object class extension to get the key of the give value

Return: (String)

Parameters:

  • value: (any) Value to compare against

Overloads:

None


map


Info: Object class extension to apply method to every value

Return: (void)

Parameters:

  • callback: (ObjectIterator<T, TValue>) Callback to apply to each value
  • craydent_ctxObject?: (any) Context for the callback function

Overloads:

None


merge


Info: Object class extension to merge objects

Return: (Object)

Parameters:

  • secondary: (Object) Object to merge with
  • condition?: (MergeEnums|MergeOptions|MergeIterator) Flags to recurse, merge only shared value, clone, intersect etc

Overloads:

None


set


Info: Alias to setProperty; however, it can not be used as a protoype property.

Return: (Bool)

Parameters:

  • object: (Object) object to add the property to
  • path: (String) Path to nested property
  • value: (any) Value to set
  • delimiter?: (Char) Separator used to parse path

Overloads:

None


setProperty


Info: Object class extension to set nested properties creating necessary property paths

Return: (Bool)

Parameters:

  • path: (String) Path to nested property
  • value: (any) Value to set
  • delimiter?: (Char) Separator used to parse path

Overloads:

None


toStringAlt


Info: Object class extension for an alternate way to stringify object to formatted string

Return: (String)

Parameters:

  • delimiter?: (Char) Character to separate the property from the value
  • prefix?: (Char) Character to prefix the property name
  • urlEncode?: (Bool) Flag to url encode the property and value

Overloads:

None

Download