![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
node-helper-utilities
Advanced tools
a generic utilities library for node.js
Install and use it via npm.
npm install node-helper-utilities --save
var util = require('./');
var obj = {
a: false,
b: true
};
var b = util.clean(obj);
console.log(b);
// {
// b: true
// }
var util = require('./');
var obj = {
key: 'value',
key2: {
field : ['a','b']
}
};
var cloned = util.clone(obj);
var util = require('./');
var a = {
a: 'b'
};
var b = {
b: 'c'
};
var out = util.merge(a, b);
Takes optional config
as follow:
{
"enable": true,
"instances": 5
}
By default, the instances
is set to (Max CPUs - 1).
var util = require('./');
var http = require('http');
function start() {
http.createServer(function(req, res) {}).listen(3000);
}
util.cluster(function() {
// start server...
start();
});
// Or using configs.
util.cluster(config, function() {
// start server...
start();
});
Create uniquely generated tokens.
var util = require('./');
util
.unique()
.then(function(token) {
console.log(token);
})
.catch(function(err) {
// some error happened;
console.log(err);
});
// or allow prefix.
util
.unique('someprefix')
.then(function(token) {
console.log(token); // someprefix:<unique>
})
.catch(function(err) {
assert(err);
});
bcrypt
)var util = require('./');
util
.hash('password')
.then(function(hashed) {
console.log(hashed);
})
.catch(function(err) {
console.log(err);
});
util
.compare('password', hashed)
.then(function(result) {
console.log(result);
})
.catch(function(err) {
console.log(err);
});
Defer a function to a later time (default: 0 ms, ie. next iteration)
var util = require('./');
util
.defer(100)
.then(function() {
console.log('this happened 100 ms later!');
});
console.log('this happens immediately!');
Often when you deal with async processes and have to pass data as JSON around, there is always potential for errors. This function is to parse json safely, and return a promise.
var util = require('./');
var couldBeJSONcouldBeString = ...;
util
.parse(couldBeJSONcouldBeString)
.then(function(parsed) {
// parsed version of `couldBeJSONcouldBeString`
console.log(parsed);
})
.catch(function(err) {
// handle error here
console.log(err);
});
var util = require('./');
var path = 'some_path';
util
.write(path, 'hello world!')
.then(function() {
return util.read(path);
})
.then(function(data) {
console.log(data); // hello world!
})
.catch(function(err) {
console.log(err.stack);
});
var util = require('./');
var str = 'h';
var padded = util.padder(str, { prefix: 'x', length: 5 });
console.log(padded); // 'xxxxh'
All tests are within tests
.
Run tests using make test
or make test-cov
for test coverage.
TravisCI build is tested against all versions >= 4.x
FAQs
Generic helper utilities
The npm package node-helper-utilities receives a total of 2 weekly downloads. As such, node-helper-utilities popularity was classified as not popular.
We found that node-helper-utilities 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.