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 2.0.17 to 2.0.18

2

package.json
{
"name": "core-functions",
"version": "2.0.17",
"version": "2.0.18",
"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",

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

# core-functions v2.0.17
# core-functions v2.0.18

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

### 2.0.18
- Backport of 3.0.11 changes to `strings` module:
- Changed `stringify` to survive a getter that throws an error
### 2.0.17

@@ -109,0 +113,0 @@ - Backport of the `errors` module from version 3.0.10

'use strict';
// noinspection JSUnusedGlobalSymbols
/**

@@ -172,7 +173,12 @@ * Module containing utilities for working with strings.

const propertyName = names[i];
const propertyValue = value[propertyName];
if (i > 0) {
result += ',';
}
result += `"${propertyName}":${stringifyWithHistory(propertyValue, `${name}.${propertyName}`, true)}`
// Avoid failing if an error is thrown from a getter
try {
const propertyValue = value[propertyName];
result += `"${propertyName}":${stringifyWithHistory(propertyValue, `${name}.${propertyName}`, true)}`;
} catch (err) {
result += `"${propertyName}":[Getter failed - ${err}]`;
}
}

@@ -179,0 +185,0 @@ result += '}';

@@ -21,2 +21,3 @@ 'use strict';

function wrap(value, wrapInString) {
// noinspection JSPrimitiveTypeWrapperUsage
return wrapInString && !(value instanceof String) ? new String(value) : value;

@@ -717,2 +718,19 @@ }

t.end();
});
test('stringify must survive a broken getter', t => {
const o = {x: {reading: true}, get y() { return this.x.reading; }};
let expected = '{"x":{"reading":true},"y":true}';
t.equal(Strings.stringify(o), expected, `stringify({x: {reading: true}, get y() { return this.x.reading; }}) must be '${expected}'`);
// Now break the 'y' getter
o.x = null;
t.throws(() => o.y, TypeError, 'o.y must throw a TypeError');
t.throws(() => o['y'], TypeError, `o['y'] must throw a TypeError`);
// but regardless, stringify must NOT break
expected = '{"x":null,"y":[Getter failed - TypeError: Cannot read property \'reading\' of null]}';
t.equal(Strings.stringify(o), expected, `stringify({x: null, get y() { return this.x.reading; }}) must be '${expected}'`);
t.end();
});
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