Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

core-functions

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-functions - npm Package Compare versions

Comparing version 3.0.15 to 3.0.16

18

errors.js

@@ -22,6 +22,10 @@ 'use strict';

* @param {string} message - a message for this error.
* @param {Error|undefined} [cause] - the error that caused this fatal error (if any)
*/
constructor(message) {
constructor(message, cause) {
super(message);
setTypeName(this.constructor);
if (cause) {
Object.defineProperty(this, 'cause', {value: cause, enumerable: false, writable: false, configurable: false});
}
}

@@ -42,6 +46,10 @@

* @param {string} message - a message for this error.
* @param {Error|undefined} [cause] - the error that caused this transient error (if any)
*/
constructor(message) {
constructor(message, cause) {
super(message);
setTypeName(this.constructor);
if (cause) {
Object.defineProperty(this, 'cause', {value: cause, enumerable: false, writable: false, configurable: false});
}
}

@@ -62,6 +70,10 @@

* @param {string} message - a message for this error.
* @param {Error|undefined} [cause] - the error that caused this fatal error (if any)
*/
constructor(message) {
constructor(message, cause) {
super(message);
setTypeName(this.constructor);
if (cause) {
Object.defineProperty(this, 'cause', {value: cause, enumerable: false, writable: false, configurable: false});
}
}

@@ -68,0 +80,0 @@

2

package.json
{
"name": "core-functions",
"version": "3.0.15",
"version": "3.0.16",
"description": "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.",

@@ -5,0 +5,0 @@ "author": "Byron du Preez",

@@ -522,10 +522,11 @@ 'use strict';

* @param {Object|undefined} [opts.skipSimplifyOutcomes] - whether to skip applying `Try.simplify` to any list of outcomes or not (defaults to simplifying with `Try.simplify`)
* @param {BasicLogger|undefined} [logger] - an optional alternative logger to use instead of the default `console` logger
* @returns {*|Promise.<*>|Promise.<Outcomes|CancelledError>} the given non-promise value or a single promise of one or
* more non-promise values/outcomes (if not cancelled); or a rejected promise with a `CancelledError` (if cancelled)
*/
function flatten(value, cancellable, opts) {
function flatten(value, cancellable, opts, logger) {
if (isPromiseLike(value)) {
// If value is a promise or promise-like then flatten its resolved value or rejected error
const p = value.then(v => flatten(v, cancellable, opts));
avoidUnhandledPromiseRejectionWarning(p);
// If value is a promise or promise-like then flatten its resolved value
const p = value.then(v => flatten(v, cancellable, opts, logger));
avoidUnhandledPromiseRejectionWarning(p, logger);
return p;

@@ -537,3 +538,3 @@ }

// then use the `every` function to "flatten" all of its resulting promises into a single promise of "simplified" outcomes
const promise = every(value.map(v => flatten(v, cancellable, opts)), cancellable);
const promise = every(value.map(v => flatten(v, cancellable, opts, logger)), cancellable);
return !opts || !opts.skipSimplifyOutcomes ? promise.then(outcomes => Try.simplify(outcomes)) : promise;

@@ -543,7 +544,7 @@

// If value is a Success outcome, then flatten its Success value too
return value.map(v => flatten(v, cancellable, opts));
return value.map(v => flatten(v, cancellable, opts, logger));
} else if (isArray && value.some(v => v instanceof Success)) {
// If value is an array containing at least one Success outcome, then flatten any Success values too
const outcomes = value.map(v => v instanceof Success ? v.map(vv => flatten(vv, cancellable, opts)) : v);
const outcomes = value.map(v => v instanceof Success ? v.map(vv => flatten(vv, cancellable, opts, logger)) : v);
return !opts || !opts.skipSimplifyOutcomes ? Try.simplify(outcomes) : outcomes;

@@ -684,10 +685,11 @@ }

* @param {Promise|PromiseLike|*} p - a promise to which to attach an arbitrary `catch`
* @param {BasicLogger|undefined} [logger] - an optional alternative logger to use instead of the default `console` logger
*/
function avoidUnhandledPromiseRejectionWarning(p) {
function avoidUnhandledPromiseRejectionWarning(p, logger) {
if (p && p.catch) {
p.catch(err => {
// Avoid unneeded warnings: (node:18304) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: ...): ...
console.log(`Avoided UnhandledPromiseRejectionWarning - ${err}`);
(logger && logger.log ? logger : console).log('TRACE', `Avoiding UnhandledPromiseRejectionWarning - ${err}`);
});
}
}

@@ -1,2 +0,2 @@

# core-functions v3.0.15
# core-functions v3.0.16

@@ -3,0 +3,0 @@ Core functions, utilities and classes for working with Node/JavaScript primitives and built-in objects, including

## Changes
### 3.0.16
- Changes to `errors` module:
- Added new optional `cause` constructor parameters & properties to `FatalError`, `TransientError` & `TimeoutError` classes
- Changes to `promises` module:
- Added new optional `logger` parameters to `flatten` & `avoidUnhandledPromiseRejectionWarning` functions to enable or
disable TRACE-level logging of their attempts to avoid unhandled promise rejection warnings
### 3.0.15

@@ -4,0 +11,0 @@ - Replaced all logging of `error.stack` with logging of just the error

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc