npm install @abeai/node-utils``
MacBook Pro (15-inch, 2018) v10.15 (19A603)
2.6 GHz 6-Core Intel Core i7
32 GB 2400 MHz DDR4
┌────────────────────────┬─────────────────────────────┬────────────────────────────────┐
│ Name │ Node-Utils │ Old │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ Get-Lodash │ 4234345 ops/s | +422.22% │ 810835 ops/s | x5.22 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ Set-Lodash │ 3179749 ops/s | +527.10% │ 507055 ops/s | x6.27 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ toPath-Lodash │ 578923 ops/s | +157.54% │ 224788 ops/s | x2.58 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ isObject-Lodash │ 925387752 ops/s | +0.10% │ 924506336 ops/s | x1.00 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ snakeCase-Lodash │ 11846262 ops/s | +353.94% │ 2609630 ops/s | x4.54 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ camelCase-Lodash │ 7228157 ops/s | +272.86% │ 1938551 ops/s | x3.73 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ kebabCase-Lodash │ 10954872 ops/s | +327.54% │ 2562305 ops/s | x4.28 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ Mapkeys-Lodash │ 4058951 ops/s | +590.54% │ 587798 ops/s | x6.91 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ Mapkeys-AltMap │ 4163350 ops/s | +149.15% │ 1671015 ops/s | x2.49 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ ForEach-Lodash │ 33148953 ops/s | +3170.51% │ 1013571 ops/s | x32.71 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ Debounce-Lodash │ 453294 ops/s | +50.37% │ 301450 ops/s | x1.50 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ Clone-Lodash │ 204591656 ops/s | +1276.91% │ 14858709 ops/s | x13.77 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ CloneDeep-Lodash │ 1447731 ops/s | +180.19% │ 516701 ops/s | x2.80 slower │
├────────────────────────┼─────────────────────────────┼────────────────────────────────┤
│ Request-RequestPromise │ 7593 ops/s | +1443.29% │ 492 ops/s | x15.43 slower │
└────────────────────────┴─────────────────────────────┴────────────────────────────────┘
`
Timer class for keeping accurate stop watch like time.
PGEncryptModelPostgres Active Model class to extend a custom model from.
Postgres Base Model class to extend a custom model from.
Postgres Connecter to initialize the singleton for connection.
PGBaseModelPostgres Encryption Model class to extend a custom model from.
The types of fields for Postgres Models.
StringConverts string to camel case.
*This method is like clone except that it recursively clones value.
*This method is like cloneWith except that it recursively clones value.
ObjectThis method is like assign except that it recursively merges own and
inherited enumerable string keyed properties of source objects into the
destination object. Source properties that resolve to undefined are
skipped if a destination value exists. Array and plain object properties
are merged recursively. Other objects and value types are overridden by
assignment. Source objects are applied from left to right. Subsequent
sources overwrite property assignments of previous sources.
Note: This method mutates object.
functionCreates a debounced function that delays invoking func until after wait
milliseconds have elapsed since the last time the debounced function was
invoked. The debounced function comes with a cancel method to cancel
delayed func invocations and a flush method to immediately invoke them.
Provide options to indicate whether func should be invoked on the
leading and/or trailing edge of the wait timeout. The func is invoked
with the last arguments provided to the debounced function. Subsequent
calls to the debounced function return the result of the last func
invocation.
Note: If leading and trailing options are true, func is
invoked on the trailing edge of the timeout only if the debounced function
is invoked more than once during the wait timeout.
If wait is 0 and leading is false, func invocation is deferred
until to the next tick, similar to setTimeout with a timeout of 0.
See David Corbacho's article
for details over the differences between _.debounce and _.throttle.
Array | ObjectIterates over elements of collection and invokes iteratee for each element.
The iteratee is invoked with three arguments: (value, index|key, collection).
Iteratee functions may exit iteration early by explicitly returning false.
*Gets the value at path of object. If the resolved value isundefined, the defaultValue is returned in its place.
booleanChecks if value is an empty object or array
Objects are considered empty if they have no own enumerable string keyed
properties.
booleanChecks if value is the
language type
of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))
StringConverts string to
kebab case.
StringConverts Object's keys from snake,kebab and space case to
camel case.
ObjectThis method creates an object with the
same values as object and keys generated by running each own enumerable
string keyed property of object thru iteratee. The iteratee is invoked
with two arguments: (value, key).
PromiseMakes a HTTP/S Request to a given url.
ObjectSets the value at path of object. If a portion of path doesn't exist,
it's created. Arrays are created for missing index properties while objects
are created for all other missing properties.
Note: This method mutates object.
StringConverts string to
snake case.
ArrayConverts value to a property path array.
Kind: global class
* Timer
* new Timer(startTime, totalTime)
* .start() ⇒ Timer
* .stop() ⇒ Timer
* .ns() ⇒ Number
* .us() ⇒ Number
* .ms() ⇒ Number
Returns: Timer - Returns the new Timer instance.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| startTime | BigInt | 0 | the time the Timer started at. |
| totalTime | BigInt | 0 | the total time the Timer elapsed. |
Kind: instance method of Timer
Returns: Timer - Returns it's self.
Kind: instance method of Timer
Returns: Timer - Returns it's self.
Kind: instance method of Timer
Returns: Number - ns.
Kind: instance method of Timer
Returns: Number - us.
Kind: instance method of Timer
Returns: Number - ms.
PGEncryptModelKind: global class
Extends: PGEncryptModel
* PGActiveModel ⇐ PGEncryptModel
* _instance_
* .addProperty(name, value)
* .find() ⇒ PGActiveModel
* .delete() ⇒ PGActiveModel
* .create() ⇒ PGActiveModel
* .save() ⇒ PGActiveModel
* .update() ⇒ PGActiveModel
* .decrypt(...props) ⇒ PGActiveModel
* .encrypt(...props) ⇒ PGActiveModel
* .redactSensitiveData(redactionCensor) ⇒ PGActiveModel
* .getEncryptedProfile() ⇒ String
* _static_
* .create(model) ⇒ PGActiveModel
* .findById(id) ⇒ PGActiveModel
* .findLimtedBy(fieldValues, operator, limit) ⇒ Array.<PGActiveModel>
* .findAllBy(fieldValues, operator) ⇒ Array.<PGActiveModel>
* .findAll() ⇒ Array.<PGActiveModel>
* .deleteById(id) ⇒ PGActiveModel
* .deleteLimitedBy(fieldValues, operator, limit) ⇒ Array.<PGActiveModel>
* .deleteAllBy(fieldValues, operator) ⇒ Array.<PGActiveModel>
* .deleteAll() ⇒ Array.<PGActiveModel>
* .updateById(id, model, returnModel) ⇒ PGActiveModel
* .updateLimitedBy(fieldValues, model, operator, returnModel, limit) ⇒ Array.<PGActiveModel>
* .updateAllBy(fieldValues, model, operator, returnModel) ⇒ Array.<PGActiveModel>
* .updateAll(model) ⇒ Array.<PGActiveModel>
Kind: instance method of PGActiveModel
| Param | Type | Description |
| --- | --- | --- |
| name | String | The name of the property. |
| value | Any | The the value to set the property. |
Kind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
$3
Deletes the current model by its set field with type PGTypes.PKKind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
$3
Creates a new row with the currently set properties.Kind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
$3
Saves the model with its changed properties.Kind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
$3
Updates the model with the passed in changed properties.Kind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
$3
Decrypts the properties on the model based on which stringed names are passed in as arguments.Kind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
| Param | Type | Description |
| --- | --- | --- |
| ...props | String | name of each property. |
$3
Encrypts the properties on the model based on which stringed names are passed in as arguments.Kind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
| Param | Type | Description |
| --- | --- | --- |
| ...props | String | name of each property. |
$3
Redacts all encrypted fields from the model.Kind: instance method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| redactionCensor | String | "[redacted]" | The string to replace the encrypted values with. |
$3
Gets the encrypted profile that the model has set.Kind: instance method of PGActiveModel
Returns: String - Returns it's self.
$3
Creates a new row with the passed in props and values.Kind: static method of PGActiveModel
Returns: PGActiveModel - Returns it's self.
| Param | Type | Description |
| --- | --- | --- |
| model | Object | A plain object with the name of the properties and their values to be set with the new model. |
Example
`js
create({
username: 'foo',
email: 'test@test.com',
});
`
$3
Retrives a model by it's PK.Kind: static method of PGActiveModel
Returns: PGActiveModel - Returns a new model.
| Param | Type | Description |
| --- | --- | --- |
| id | String | The PK of the model to retrieve. |
$3
Retrives a limited amount models by the passed in fieldValues.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of new models.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| fieldValues | Object | | A plain object with the properties and their values to retrive by. |
| operator | String | AND | The query operator to use between each of the
fieldValues [AND, OR, 'NOT'] |
| limit | Number | | The limit to stop searching when the records retrived are equal or greater than the set limit. |Example
`js
findLimtedBy({
username: ['user2', 'OR', 'user3'],
email: null,
}, 'AND', 5);
`
$3
Retrives all models by the passed in fieldValues. Will stop searching when the records retrived are equal or greater than limit.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of new models.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| fieldValues | Object | | A plain object with the properties and their values to retrive by. |
| operator | String | AND | The query operator to use between each of the fieldValues [
AND, OR, 'NOT'] |Example
`js
findAllBy({
username: ['user2', 'OR', 'user3'],
email: null,
}, 'AND');
`
$3
Retrives all rows in the table of the model.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of new models.
$3
Deletes a model that is found by it's PK with the passed in props and values.Kind: static method of PGActiveModel
Returns: PGActiveModel - Returns a new model or null
| Param | Type | Description |
| --- | --- | --- |
| id | String | The PK of the model to delete. |
$3
Deletes a limited amount models by the passed in fieldValues.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of deleted models.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| fieldValues | Object | | A plain object with the properties and their values to delete by. |
| operator | String | AND | The query operator to use between each of the fieldValues [
AND, OR, 'NOT'] |
| limit | Number | | The limit to stop deleting when the records retrived are equal or greater than the set limit. |Example
`js
deleteLimitedBy({
registered: false,
},'AND', 5);
`
$3
Deletes all models by the passed in fieldValues.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of deleted models.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| fieldValues | Object | | A plain object with the properties and their values to delete by. |
| operator | String | AND | The query operator to use between each of the
fieldValues [AND, OR, 'NOT'] |Example
`js
deleteAllBy({
registered: true,
});
`
$3
Deletes all models in their table.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of deleted models or null
$3
Updates a model that is found by it's PK with the passed in props and values.Kind: static method of PGActiveModel
Returns: PGActiveModel - Returns a new model or null
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| id | String | | The PK of the model to update. |
| model | Object | | A plain object with the name of the properties and their values to update the model with. |
| returnModel | Boolean | true | If the updated model should be returned or not. It will return null if this is set to false. |
Example
`js
updateById('09A75A84-A921-4F68-8FEF-B8392E3702C2',
{
password: 'bestpasswordinalltheland12346969420'
});
`
$3
Updates models that are found by the passed in fieldValues with the passed in props and values of the model.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of updated models or null
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| fieldValues | Object | | A plain object with the properties and their values to update by. |
| model | Object | | A plain object with the name of the properties and their values to update the model with. |
| operator | String | AND | The query operator to use between each of the
fieldValues [AND, OR, 'NOT'] |
| returnModel | Boolean | true | If the updated model should be returned or not. It will return null if this is set to false. |
| limit | Number | | The limit to stop searching when the records retrived are equal or greater than the set limit. |Example
`js
updateLimitedBy({
password: null
},
{
password: 'bestpasswordinalltheland12346969420'
},'AND', true, 5);
`
$3
Updates all models that are found by the passed in fieldValues with the passed in props and values of the model.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of updated models or null
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| fieldValues | Object | | A plain object with the properties and their values to update by. |
| model | Object | | A plain object with the name of the properties and their values to update the model with. |
| operator | String | AND | The query operator to use between each of the
fieldValues [AND, OR, 'NOT'] |
| returnModel | Boolean | true | If the updated model should be returned or not. It will return null if this is set to false. |Example
`js
updateAllBy({
password: null
},
{
password: 'bestpasswordinalltheland12346969420'
});
`
$3
Updates all models in their table with the passed in props and values of the model.Kind: static method of PGActiveModel
Returns: Array.<PGActiveModel> - Returns an array of updated models or null
| Param | Type | Description |
| --- | --- | --- |
| model | Object | A plain object with the name of the properties and their values to update the models with. |
Example
`js
updateAll({
password: 'bestpasswordinalltheland12346969420'
});
`
PGBaseModel
Postgres Base Model class to extend a custom model from.PGConnecter
Postgres Connecter to initialize the singleton for connection.$3
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| options | Object | | The connection options. |
| options.crypto | Crypto | postgres/crypto/interface.js | The implemented crypto interface that follows
postgres/crypto/interface.js |
| options.pg | Object | | The options object to pass into pg lib. |
| options.pg.user | String | process.env.PGUSER | User's name. |
| options.pg.password | String | process.env.PGPASSWORD | User's password. |
| options.pg.database | String | process.env.PGDATABASE | Database's name. |
| options.pg.port | Number | process.env.PGPORT | Database's port. |
| options.pg.connectionString | String | | Postgres formated connection string. e.g. postgres://user:password@host:5432/database |
| options.pg.ssl | TLSSocket | | Options to be passed into the native Node.js TLSSocket socket. |
| options.pg.types | pg.types | | Custom type parsers. See node-postgres types for more details. |
| options.pg.statement_timeout | Number | 0 | Number of milliseconds before a statement in query will time out. |
| options.pg.query_timeout | Number | 0 | number of milliseconds before a query call will timeout. |
| options.pg.connectionTimeoutMillis | Number | 0 | Number of milliseconds to wait before timing out when connecting a new client. |
| options.pg.idleTimeoutMillis | Number | 10000 | Number of milliseconds a client must sit idle in the pool and not be checked out before it is disconnected from the backend and discarded. |
| options.pg.max | Number | 10 | Maximum number of clients the pool should contain. |Example
`js
var pgOptions = {
pg: {
connectionString: 'postgres://postgres@localhost/pgtest',
}
};try {
pgOptions.crypto = require('@abeai/node-crypto').utils.pgCrypto;
} catch (_) {
console.log(_);
}
var pg = new PGConnecter(pgOptions);
`
PGEncryptModel ⇐ PGBaseModel
Postgres Encryption Model class to extend a custom model from.Kind: global class
Extends: PGBaseModel
PGTypes
The types of fields for Postgres Models.Kind: global constant
* PGTypes
* .PK
* .Encrypt
* .EncryptWithoutHash
* .EncryptProfile
* .AutoCrypt
* .AutoCryptWithoutHash
* .Hash
$3
The primary key of the table.Kind: static property of PGTypes
$3
Marks this field to auto encrypt/hash (for look up) but not auto decrypt it on retrieval.
The table will need to have a field with the same name as this set field with __ as a prefix.Kind: static property of PGTypes
Example
`js
//if you have an encrypted field called phone the sql query for creating the table may look like this
CREATE TABLE IF NOT EXISTS users (
phone VARCHAR (500),
__phone VARCHAR (500) UNIQUE,
);
`
$3
Marks this field to auto encrypt but not auto decrypt it on retrieval.
Same as Encrypt but with no lookup hash.Kind: static property of PGTypes
$3
Marks this field as the encryption profile for encrypting/decrypting/hashing utilizing aws kms.Kind: static property of PGTypes
$3
Marks this field to auto encrypt/hash (for look up) and to auto decrypt it on retrieval.Kind: static property of PGTypes
$3
Marks this field to auto encrypt and auto decrypt it on retrieval.
Same as AutoCrypt but with no lookup hash.Kind: static property of PGTypes
$3
Marks this field to be hashed on creation (IE: Password and other information you want to protect)Kind: static property of PGTypes
camelCase(str) ⇒ String
Converts string to camel case.Kind: global function
Returns: String - Returns the camel cased string.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| str | String | '' | The string to convert. |
Example
`js
camelCase('Foo Bar');
// => 'fooBar'camelCase('--foo-bar--');
// => 'fooBar'
camelCase('__FOO_BAR__');
// => 'fooBar'
`
cloneDeep(value) ⇒ \*
This method is like clone except that it recursively clones value.Kind: global function
Returns: \* - Returns the deep cloned value.
| Param | Type | Description |
| --- | --- | --- |
| value | \* | The value to recursively clone. |
Example
`js
var objects = [{ 'a': 1 }, { 'b': 2 }];var deep = cloneDeep(objects);
console.log(deep[0] === objects[0]);
// => false
`
cloneDeepWith(value, [cb]) ⇒ \*
This method is like cloneWith except that it recursively clones value.Kind: global function
Returns: \* - Returns the deep cloned value.
| Param | Type | Description |
| --- | --- | --- |
| value | \* | The value to recursively clone. |
| [cb] | function | The function to customize cloning. |
Example
`js
function customizer(value) {
if (_.isElement(value)) {
return value.cloneNode(true);
}
}var el = cloneDeepWith(document.body, customizer);
console.log(el === document.body);
// => false
console.log(el.nodeName);
// => 'BODY'
console.log(el.childNodes.length);
// => 20
`
merge(object, [...sources]) ⇒ Object
This method is like assign except that it recursively merges own and
inherited enumerable string keyed properties of source objects into the
destination object. Source properties that resolve to undefined are
skipped if a destination value exists. Array and plain object properties
are merged recursively. Other objects and value types are overridden by
assignment. Source objects are applied from left to right. Subsequent
sources overwrite property assignments of previous sources.Note: This method mutates
object.Kind: global function
Returns: Object - Returns
object. | Param | Type | Description |
| --- | --- | --- |
| object | Object | The destination object. |
| [...sources] | Object | The source objects. |
Example
`js
var object = {
'a': [{ 'b': 2 }, { 'd': 4 }]
};var other = {
'a': [{ 'c': 3 }, { 'e': 5 }]
};
merge(object, other);
// => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
`
debounce(func, delay) ⇒ function
Creates a debounced function that delays invoking func until after wait
milliseconds have elapsed since the last time the debounced function was
invoked. The debounced function comes with a cancel method to cancel
delayed func invocations and a flush method to immediately invoke them.
Provide options to indicate whether func should be invoked on the
leading and/or trailing edge of the wait timeout. The func is invoked
with the last arguments provided to the debounced function. Subsequent
calls to the debounced function return the result of the last func
invocation.Note: If
leading and trailing options are true, func is
invoked on the trailing edge of the timeout only if the debounced function
is invoked more than once during the wait timeout.If
wait is 0 and leading is false, func invocation is deferred
until to the next tick, similar to setTimeout with a timeout of 0.See David Corbacho's article
for details over the differences between
_.debounce and _.throttle.Kind: global function
Returns: function - Returns the new debounced function.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| func | function | | The function to debounce. |
| delay | Number | 0 | The number of milliseconds to delay. |
Example
`js
// Avoid costly calculations while the window size is in flux.
jQuery(window).on('resize', debounce(calculateLayout, 150));// Invoke
sendMail when clicked, debouncing subsequent calls.
jQuery(element).on('click', debounce(sendMail, 300, {
'leading': true,
'trailing': false
}));// Ensure
batchLog is invoked once after 1 second of debounced calls.
var debounced = debounce(batchLog, 250, { 'maxWait': 1000 });
var source = new EventSource('/stream');
jQuery(source).on('message', debounced);// Cancel the trailing debounced invocation.
jQuery(window).on('popstate', debounced.cancel);
`
forEach(collection, cb) ⇒ Array \| Object
Iterates over elements of collection and invokes iteratee for each element.
The iteratee is invoked with three arguments: (value, index|key, collection).
Iteratee functions may exit iteration early by explicitly returning false.Kind: global function
Returns: Array \| Object - Returns
collection. | Param | Type | Description |
| --- | --- | --- |
| collection | Array \| Object | The collection to iterate over. |
| cb | function | The function invoked per iteration. |
Example
`js
forEach([1, 2], function(value) {
console.log(value);
});
// => Logs 1 then 2.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
console.log(key);
});
// => Logs 'a' then 'b' (iteration order is not guaranteed).
`
get(object, path, [defaultReturn]) ⇒ \*
Gets the value at path of object. If the resolved value is
undefined, the defaultValue is returned in its place.Kind: global function
Returns: \* - Returns the resolved value.
| Param | Type | Description |
| --- | --- | --- |
| object | Object | The object to query. |
| path | Array | The path of the property to get. |
| [defaultReturn] | \* | The value returned for
undefined resolved values. |Example
`js
var object = { 'a': [{ 'b': { 'c': 3 } }] };get(object, 'a[0].b.c');
// => 3
get(object, ['a', '0', 'b', 'c']);
// => 3
`
isEmpty(value) ⇒ boolean
Checks if value is an empty object or arrayObjects are considered empty if they have no own enumerable string keyed
properties.
Kind: global function
Returns: boolean - Returns
true if value is empty, else false. | Param | Type | Description |
| --- | --- | --- |
| value | \* | The value to check. |
Example
`js
isEmpty({});
// => trueisEmpty([]);
// => true
isEmpty([1, 2, 3]);
// => false
isEmpty({ 'a': 1 });
// => false
`
isObject(value) ⇒ boolean
Checks if value is the
language type
of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))Kind: global function
Returns: boolean - Returns
true if value is an object, else false. | Param | Type | Description |
| --- | --- | --- |
| value | \* | The value to check. |
Example
`js
isObject({});
// => trueisObject([1, 2, 3]);
// => true
isObject(null);
// => false
`
kebabCase(str) ⇒ String
Converts string to
kebab case.Kind: global function
Returns: String - Returns the kebab cased string.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| str | String | '' | The string to convert. |
Example
`js
kebabCase('Foo Bar');
// => 'foo-bar'kebabCase('fooBar');
// => 'foo-bar'
kebabCase('__FOO_BAR__');
// => 'foo-bar'
`
keysToCamel(o) ⇒ String
Converts Object's keys from snake,kebab and space case to
camel case.Kind: global function
Returns: String - Returns the object with it's key's camelcased.
| Param | Type | Description |
| --- | --- | --- |
| o | Object | The object to convert. |
Example
`js
keysToCamel({foo_bar:{bar_meme:20}})
// => {fooBar:{barMeme:20}}
`
mapKeys(object, iteratee) ⇒ Object
This method creates an object with the
same values as object and keys generated by running each own enumerable
string keyed property of object thru iteratee. The iteratee is invoked
with two arguments: (value, key).Kind: global function
Returns: Object - Returns the new mapped object.
| Param | Type | Description |
| --- | --- | --- |
| object | Object | The object to iterate over. |
| iteratee | function | The function invoked per iteration. |
Example
`js
mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
return key + value;
});
// => { 'a1': 1, 'b2': 2 }
`
request(options) ⇒ Promise
Makes a HTTP/S Request to a given url.Kind: global function
Returns: Promise - Returns the promise that gets resolved or rejected.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| options | Object | | Supports all of nodes HTTP/S Module's options + the folloing. |
| options.uri | String | | fully qualified uri. |
| options.method | String | GET | http method. |
| options.headers | Object | {} | http headers. |
| options.qs | Object | | object containing querystring values to be appended to the
uri. |
| options.simple | Boolean | true | throws an error for any non 2xx status code response. |
| options.resolveWithFullResponse | Boolean | false | set to true if the full response object is wanted instead of just the body data. |
| options.qs | Object | | object containing querystring values to be appended to the uri. |
| options.body | Object \| Buffer \| String \| ReadSteam | | entity body for PATCH, POST and PUT requests. Must be a Buffer, String or ReadStream. If json is true, then body must be a JSON-serializable object. |
| options.form | Object | | when passed an object or a querystring, this sets body to a querystring representation of value, and adds Content-type: application/x-www-form-urlencoded header. |
| options.json | Boolean | | setsbody to JSON representation of value and adds Content-type: application/json header. Additionally, parses the response body as JSON. |
| options.keepAlive | Boolean | true | set to false to turn off keepAlive sockets. |
| options.authorization.basic | Object | | takes an object with client and secret props to create a Authorization: Basic client:secret base64 header. |
| options.authorization.bearer | String | | creates a Authorization: Bearer bearer header. |
| options.redirectMax | Number | 5 | number of times the request will follow a redirect from the server. |
| options.logger | Object | | the pino logger to log errors. |Example
`js
await request({
uri: 'http://127.0.0.1:4261/'),
simple: false,
resolveWithFullResponse: true
});
`
set(object, path, value) ⇒ Object
Sets the value at path of object. If a portion of path doesn't exist,
it's created. Arrays are created for missing index properties while objects
are created for all other missing properties.Note: This method mutates
object.Kind: global function
Returns: Object - Returns
object. | Param | Type | Description |
| --- | --- | --- |
| object | Object | The object to modify. |
| path | Array | The path of the property to set. |
| value | \* | The value to set. |
Example
`js
var object = { 'a': [{ 'b': { 'c': 3 } }] };set(object, ['x', '0', 'y', 'z'], 5);
console.log(object.x[0].y.z);
// => 5
`
snakeCase(str) ⇒ String
Converts string to
snake case.Kind: global function
Returns: String - Returns the snake cased string.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| str | String | '' | The string to convert. |
Example
`js
snakeCase('Foo Bar');
// => 'foo_bar'snakeCase('fooBar');
// => 'foo_bar'
snakeCase('--FOO-BAR--');
// => 'foo_bar'
`
toPath(value) ⇒ Array
Converts value to a property path array.Kind: global function
Returns: Array - Returns the new property path array.
| Param | Type | Description |
| --- | --- | --- |
| value | String | The value to convert. |
Example
`js
toPath('a.b.c');
// => ['a', 'b', 'c']toPath('a[0].b.c');
// => ['a', '0', 'b', 'c']
``