API

crio API

Instantiation

  • crio {any}, returns CrioArray|CrioObject
    • Standard method, will crio the object passed if an array or object, else it will return the object itself
  • crio.array {Array<any>}, returns CrioArray
    • Shortcut method for crioing array-specific values
  • crio.object {Object}, returns CrioObject
    • Shortcut method for crioing object-specific values
  • crio.isCrio {any}, returns boolean
    • Determine if the object passed is a Crio
  • crio.isArray {any}, returns boolean
    • Determine if the object passed is a CrioArray
  • crio.isObject {any}, returns boolean
    • Determine if the object passed is a CrioObject

Methods with the same name as the native method will be a link to MDN, as they are meant to be as similar to the native method as possible. Where any specific differences from the default behavior exist, they will be called out, however one broad difference is that all methods that are not getters which return primitive values are chainable.

Shared Methods

The following methods are specific to Crio types, and are available on either CrioArray or CrioObject

  • clear, returns {CrioArray|CrioObject}
    • returns an empty Crio
  • compact, returns {CrioArray|CrioObject}
    • returns a new Crio with all falsy values filtered out
  • delete {number} key, returns {CrioArray|CrioObject}
    • Deletes the key provided from the crio object
  • deleteIn {Array<number|string>} keys, returns {CrioArray|CrioObject}
    • Deletes the final key based on the array of keys nested inside of the crio object
  • equals {CrioArray|CrioObject} crioArrayToCompare, returns {boolean}
    • Determines whether array is deeply equal in value to another by comparing hashCodes
  • get {number} key, returns {any}
    • Retrieve value at key
  • getIn {Array<number|string>} keys, returns {any}
    • Retrieve value in deeply nested object based on array of keys
  • has {string} key, returns {boolean}
    • Alias for hasOwnProperty
  • hasIn {Array<number|string>} keys, returns {boolean}
    • Does the Crio have the combination of keys assigned deeply
  • merge {Object[, Object2, ..., ObjectN]} objects, returns {CrioArray|CrioObject}
    • Shallow merge any number of items into existing crio
  • mergeIn {Array<number|string>} keys, {Object[, Object2, ..., ObjectN]} objects, returns {CrioArray|CrioObject}
    • Shallow merge any number of items into value existing in deeply nested object based on array of keys
  • mutate {function(mutableCrio, originalCrio): any} callback, returns {CrioArray|CrioObject}
    • Whatever you return in the callback is what is returned, or if you return nothing it returns the original Crio
  • pluck {number|string} key, returns {CrioArray|CrioObject}
    • Iterates over Crio and returns an array of values where the key exists as a property on the collection item
  • pluckIn {Array<number|string} keys, returns {CrioArray|CrioObject}
    • Iterates over Crio and returns an array of values where the keys map to a deeply-nested property on the collection item
  • set {number} key, returns {CrioArray|CrioObject}
    • Sets value at key
  • setIn {Array<number|string>} keys, returns {CrioArray|CrioObject}
    • Sets value in deeply nested object based on array of keys
  • toArray, returns {CrioArray}
    • Converts CrioObject to a CrioArray of the object's values
  • toObject, returns {CrioObject}
    • Converts CrioArray into a CrioObject of index: value pairs
  • thaw, returns {Array<any>}
    • Recursively thaws array deeply and returns standard object version of itself

Arrays

Default Methods

Added crio Methods

  • difference {Array<*>} array[, array2, ..., arrayN], returns {CrioArray}
    • Returns a new array of the values that only exist in either the CrioArray or in one of the arrays passed
  • findLastIndex {function} fn, returns {number}
    • Same as findIndex but starting from end and working to start
  • first {number} num, returns {CrioArray}
    • Returns a new array of the first num number of items in the array
  • intersection {Array<*>} array[, array2, ..., arrayN], returns {CrioArray}
    • Returns a new array of the values that exist in all of the arrays passed
  • last {number} num, returns {CrioArray}
    • Returns a new array of the last num number of items in the array
  • unique, returns {CrioArray}
    • Returns a new CrioArray of values filtered down to only existing in the array once
  • xor {Array<*>} array[, array2, ..., arrayN], returns {CrioArray}
    • Returns a new array of the values that are the symmetric difference of the CrioArray and the arrays passed

Objects

Default Methods

Added crio Methods

  • entries, returns {Array<[string, any]>}
    • Gets an array of the [key, value] pairs in the CrioObject
  • every {function(value, key, CrioObject): any} fn, {any} thisArg, returns {any}
    • Performs same function as every in the Array prototype, but on the CrioObject
  • forEach {function} fn, {any} thisArg, returns {CrioObject}
    • Iterates over object executing fn
    • Iteration order is not guaranteed
  • filter {function} fn, {any} thisArg, returns {CrioObject}
    • Iterates over object and filters out any returned values that are falsy
    • Iteration order is not guaranteed
  • findKey {function} fn, returns {number}
    • Same as findIndex for CrioArray but finding the key instead of the index
  • findLastKey {function} fn, returns {number}
    • Same as findKey but starting from end and working to start
  • includes {any} value, returns {boolean}
    • Determine if the CrioObject has a value that deeply matches value in equality
  • keys, returns {Array<string>}
    • Returns an array of the keys in the CrioObject
  • map {function} fn, {any} thisArg, returns {CrioObject}
    • Iterates over object and maps returned value to the respective key
    • Iteration order is not guaranteed
  • reduce {function(accumulatedObject, value, key): any} fn, {any} thisArg, returns {any}
    • Performs same function as reduce in the Array prototype, but on the CrioObject
  • reduceRight {function(accumulatedObject, value, key): any} fn, {any} thisArg, returns {any}
    • Performs same function as reduceRight in the Array prototype, but on the CrioObject
  • some {function(value, key, CrioObject): any} fn, {any} thisArg, returns {any}
    • Performs same function as some in the Array prototype, but on the CrioObject
  • values, returns {Array<any>}
    • Returns an array of the values in the CrioObject