
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
hathor-utils
Advanced tools
Collection of utility functions for use with Hathor projects, plugins, and routes. The basic usage of each method is covered here, but full usage is covered in the tests.
NOTE: All functions in this library work in an immutable fashion, creating clones or copies of objects and never modifing the source object or values.
npm install --save hathor-utils
An empty function, no operation, useful for things like optional callbacks.
Wrapper around json-stringify-safe, useful when you want to JSON.stringify an object that may or may not have things that are compatable with JSON.
Returns a true false flag if the string filename passed in ends in html or htm.
Checks value to see if it is either "true" or a boolean true value. If so will return a boolean true. All other values return a boolean false.
Checks value to see if it is either "false" or a boolean false value. If so will return a boolean true. All other values return a boolean false.
Checks value to see if a value is a numeric value. If so will return a boolean true, if the value is a string that represents a numeric true will also be returned. All other values return a boolean false.
Creates a new object then copies all key values from source into the new object and excludes any keys provided.
Returns a new array that only contains unique values from the source aray. Useful to dedupe arrays.
Decodes a Base 64 string into a binary blob.
Encodes a value into a Base 64 string representation.
Takes key as a string and splits it on the expression provided (defaults to splitting on all .'s and /'s) then returns the resulting array. Useful for passing search paths to getObjectValue, setObjectValue, etc...
Accepts path as an array of keys to recurse through and return the value from obj. If the value is not found then returns defaultValue (undefined by default).
const src = {
foo: {
bar: {
value: 'something'
}
}
};
const value = getObjectValue(keyToPath('foo.bar.value'), src, 'value');
const noValue = getObjectValue(keyToPath('foo.bar.noValue'), src, 'nothing');
console.log(value); // outputs "something"
console.log(noValue); // outputs "nothing"
Accepts path as an array of keys to recurse through the keys creating new objects if no key exists and updating the final value.
const src = {
foo: {
}
};
const out1 = setObjectValue(keyToPath('foo'), src, 'bar');
const out2 = setObjectValue(keyToPath('foo.bar'), src, 'value');
console.log(out1); // outputs {foo: "bar"}
console.log(out2); // outputs {foo: {bar: "value"}}
Similar to exclude, but instead works with key paths and can remove embedded values from the source object.
const src = {
foo: {
bar: {
value: 'something'
}
}
};
const value = removeObjectValue(keyToPath('foo.bar.value'), src);
console.log(value); // {foo: bar: {}}
Creates a deep clone of source and merges the values from each additional argument into the new object.
const src = {foo: 'bar'};
const out = merge(src, {bar: 'none'}, {some: 'value'});
console.log(out); // {foo: 'bar', bar: 'none', some: 'value'}
Creates a deep clone of source and returns it.
If the passed value is a Date or Regular Expression a new instance is created and returned. If the value is a string, numeric, or boolean then it is returned as by default these do not require explicit cloning. If the value is an array it is mapped over returning a new array of cloned values within. If the value is an object then all keys are mapped over, checked against "hasOwnProperty" and cloned recursivly then returned.
Converts a camel cased string into an underscored uppercase string.
const input = 'testString';
const output = toUnderscore(input);
console.log(output); // TEST_STRING
Takes an object, itterates over its keys calling toUnderscore recursivly, and returns a new object with the keys in all uppercase with underscores.
Converts a string into its camel cased representation.
const input = 'TEST_STRING FOO-BAR_NONE';
const output = camelCase(input);
console.log(output); // testStringFooBarNone
Takes an object, itterates over its keys calling camelCase recursivly, and returns a new object with the keys converted to camel case.
FAQs
Utilities for use by Hathor and its plugins.
The npm package hathor-utils receives a total of 11 weekly downloads. As such, hathor-utils popularity was classified as not popular.
We found that hathor-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.