Timo Hocker
61d1534635
update-scanner: automatic update
ava: 3.8.1 ==> 3.8.2 minor eslint: 6.8.0 ==> 7.0.0 major
Utilities
General helper functions
const util = require('@scode/utilities');
// cut off decimal places to a specified point
util.truncate_decimal(12.345678, 2);
// returns 12.34
// will return null instead of throwing on invalid json
util.try_parse_json('{{foo');
// copy an object to prevent modification of the original
const obj = {foo:'bar'};
const copy = util.copy_object(obj);
copy.foo = 'baz';
console.log(obj.foo); // bar
// run a regular expression and get a callback for every result
const data = "foobarfoo";
const regex = /foo/g;
util.run_regex(regex, data, res => {
console.log(res[0]); // will output 'foo' 2 times
});
Description
Languages
JavaScript
100%