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

@stoplight/common

Package Overview
Dependencies
Maintainers
4
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/common - npm Package Compare versions

Comparing version 0.0.11-25 to 0.0.11-26

3

lib/json.d.ts
export declare const stringify: (target: any, replacer?: ((key: any, value: any) => any) | undefined, offset?: number | undefined) => any;
export declare const parse: (target: string) => any;
export declare const decycle: (target: object) => any;
export declare const getValue: (obj: any, path: string | string[], defaultVal?: boolean | undefined) => any;
export declare const setValue: (obj: any, path: string | string[], value: any) => any;
export declare const unsetValue: (obj: any, path: string | string[]) => boolean;
export declare const startsWith: (source: string | any[], val: string | any[]) => boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fast_safe_stringify_1 = require("fast-safe-stringify");
var fast_safe_stringify_1 = require("@stoplight/fast-safe-stringify");
// @ts-ignore

@@ -11,12 +11,22 @@ var _get = require("get-value");

exports.stringify = function (target, replacer, offset) {
if (target && typeof target !== 'string') {
try {
// try regular stringify first as mentioned in this tip: https://github.com/davidmarkclements/fast-safe-stringify#protip
return JSON.stringify(target, replacer, offset);
}
catch (_) {
// @ts-ignore
return fast_safe_stringify_1.default(target, replacer, offset);
}
if (!target || typeof target === 'string')
return target;
try {
// try regular stringify first as mentioned in this tip: https://github.com/davidmarkclements/fast-safe-stringify#protip
return JSON.stringify(target, replacer, offset);
}
catch (_) {
// @ts-ignore
return fast_safe_stringify_1.default(target, replacer, offset);
}
};
exports.parse = function (target) {
if (typeof target !== 'string')
return target;
return JSON.parse(target);
};
exports.decycle = function (target) {
if (typeof target !== 'object')
return target;
fast_safe_stringify_1.default.decirc(target, '', []);
return target;

@@ -33,2 +43,34 @@ };

};
exports.startsWith = function (source, val) {
if (source instanceof Array) {
if (val instanceof Array) {
if (val.length > source.length)
return false;
for (var i in val) {
if (!val.hasOwnProperty(i))
continue;
var si = parseInt(source[i]);
var vi = parseInt(val[i]);
// support if numeric index is stringified in one but not the other
if (!isNaN(si) || !isNaN(vi)) {
if (si !== vi) {
return false;
}
}
else if (source[i] !== val[i]) {
return false;
}
}
}
}
else if (typeof source === 'string') {
if (typeof val === 'string') {
return source.startsWith(val);
}
}
else {
return false;
}
return true;
};
//# sourceMappingURL=json.js.map

4

package.json
{
"name": "@stoplight/common",
"version": "0.0.11-25",
"version": "0.0.11-26",
"description": "Stoplight common type and interface definitions.",

@@ -24,3 +24,3 @@ "main": "lib/index.js",

"dependencies": {
"fast-safe-stringify": "2.0.x",
"@stoplight/fast-safe-stringify": "2.0.x",
"get-value": "3.x.x",

@@ -27,0 +27,0 @@ "set-value": "3.x.x",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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