Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
core-functions
Advanced tools
Core functions, utilities and classes for working with Node/JavaScript primitives and built-in objects, including strings, booleans, Promises, base 64, Arrays, Objects, standard AppErrors, etc.
Core functions, utilities and classes for working with Node/JavaScript primitives and built-in objects, including strings, numbers, booleans, Dates, Promises, base 64, Arrays, Objects, standard AppErrors, sorting utilities, etc.
Currently includes:
This module is exported as a Node.js module.
Using npm:
$ {sudo -H} npm i -g npm
$ npm i --save core-functions
In Node.js:
To use the any
utilities
const any = require('core-functions/any');
To use the string utilities
const Strings = require('core-functions/strings');
To use the number utilities
const Numbers = require('core-functions/numbers');
To use the boolean utilities
const Booleans = require('core-functions/booleans');
To use the Base 64 encoding and decoding utilities
const base64 = require('core-functions/base64');
To use the Date utilities
const Dates = require('core-functions/dates');
To use the sorting utilities
const sorting = require('core-functions/sorting');
To use the Promise utilities
const Promises = require('core-functions/promises');
To use the Object utilities
const Objects = require('core-functions/objects');
To use the Array utilities
const Arrays = require('core-functions/arrays');
To use the Timer utilities
const timers = require('core-functions/timers');
To use the Try
, Success
and Failure
classes
const tries = require('./tries');
const Try = tries.Try;
const Success = tries.Success;
const Failure = tries.Failure;
// Simulate getting a Success outcome from successful execution of a function, which returns a value
const outcome = Try.try(() => 'Abc');
// outcome = new Success('Abc')
assert(outcome.isSuccess());
assert(outcome.value === 'Abc');
// using map function to convert a Success('Abc') outcome's value into a Success('AbcXyz')
const outcome1 = outcome.map(v => v + 'Xyz');
assert(outcome1.isSuccess());
assert(outcome1.value === 'AbcXyz');
// Simulate getting a Failure outcome from unsuccessful execution of a function, which throws an error
const testErr = new Error("Err"); // an arbitrary error for the example
const outcome2 = Try.try(() => {throw testErr});
// outcome2 is equivalent to new Failed(new Error("Err"))
assert(outcome2.isFailure());
assert(outcome2.error === testErr);
// using recover function to convert a Failed outcome's error into a Success(123)
const outcome3 = outcome2.recover(err => 123);
assert(outcome3.isSuccess());
assert(outcome3.value === 123);
// ... or using map function to handle both successes & failures cases at the same time (similar to Promise.then)
const outcome4 = outcome.map(
value => {
return value * 42;
},
err => {
console.log(err);
return -1;
}
);
To use the standard application errors
const appErrors = require('core-functions/app-errors');
const AppError = appErrors.AppError;
// 400-series
const BadRequest = appErrors.BadRequest;
const Unauthorized = appErrors.Unauthorized;
const Forbidden = appErrors.Forbidden;
const NotFound = appErrors.NotFound;
const RequestTimeout = appErrors.RequestTimeout;
const TooManyRequests = appErrors.TooManyRequests;
// 500-series
const InternalServerError = appErrors.InternalServerError;
const BadGateway = appErrors.BadGateway;
const ServiceUnavailable = appErrors.ServiceUnavailable;
const GatewayTimeout = appErrors.GatewayTimeout;
// HTTP status codes with explicit class support and allowed to pass through to API Gateway by default
const supportedHttpStatusCodes = appErrors.supportedHttpStatusCodes;
// Error conversion functions
const toAppError = appErrors.toAppError;
const toAppErrorForApiGateway = appErrors.toAppErrorForApiGateway;
This module's unit tests were developed with and must be run with tape. The unit tests have been tested on Node.js v4.3.2.
See the package source for more details.
See release_notes.md
3.0.17
promises
module:
avoidUnhandledPromiseRejectionWarning
function to log each error and its stack trace at WARN-levelavoidUnhandledPromiseRejectionWarnings
function that applies the
avoidUnhandledPromiseRejectionWarning
function to each of the promises it is givenevery
function:
logger
3rd parameter to the every
function to enable use of a custom logger instead of consoleevery
function to call the new avoidUnhandledPromiseRejectionWarnings
function on any unresolved
promises before throwing a CancelledError
flatten
function:
flatten
function to ALWAYS return a Promiseflatten
function to rely on the fixed every
function to avoid UnhandledPromiseRejectionWarnings
instead of calling avoidUnhandledPromiseRejectionWarning
itselfdefaultFlattenOpts
sample options to use with flatten
functiontries
module:
defaultFlattenOpts
sample options to use with flatten
functionflatten
function to cache Success
values & unpacked values instead of Success
instancescopying
module:
defaultCopyOpts
sample options to use with copy
functiondefaultCopyNamedPropertiesOpts
sample options to use with copyNamedProperties
functionmerging
module:
defaultMergeOpts
sample options to use with merge
functiontype-defs
module:
FlattenOpts
& TryFlattenOpts
type definitionsFAQs
Core functions, utilities and classes for working with Node/JavaScript primitives and built-in objects, including strings, booleans, Promises, base 64, Arrays, Objects, standard AppErrors, etc.
The npm package core-functions receives a total of 48 weekly downloads. As such, core-functions popularity was classified as not popular.
We found that core-functions 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.