Socket
Socket
Sign inDemoInstall

@sentry/utils

Package Overview
Dependencies
Maintainers
9
Versions
499
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/utils - npm Package Compare versions

Comparing version 4.6.4 to 5.0.0-rc.0

error.d.ts

7

fs.d.ts
/**
* Asynchronously reads given files content.
*
* @param path A relative or absolute path to the file
* @returns A Promise that resolves when the file has been read.
*/
export declare function readFileAsync(path: string): Promise<string>;
/**
* Recursively creates the given path.

@@ -10,0 +3,0 @@ *

32

fs.js

@@ -8,27 +8,2 @@ "use strict";

/**
* Asynchronously reads given files content.
*
* @param path A relative or absolute path to the file
* @returns A Promise that resolves when the file has been read.
*/
function readFileAsync(path) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
// We cannot use util.promisify here because that was only introduced in Node
// 8 and we need to support older Node versions.
return [2 /*return*/, new Promise(function (res, reject) {
fs_1.readFile(path, 'utf8', function (err, data) {
if (err) {
reject(err);
}
else {
res(data);
}
});
})];
});
});
}
exports.readFileAsync = readFileAsync;
/**
* Asynchronously creates the given directory.

@@ -74,3 +49,3 @@ *

case 1:
_a.trys.push([1, 2, , 6]);
_a.trys.push([1, 2, , 5]);
return [2 /*return*/, mkdirAsync(realPath, mode)];

@@ -94,5 +69,4 @@ case 2:

}
_a.label = 5;
case 5: return [3 /*break*/, 6];
case 6: return [2 /*return*/];
return [3 /*break*/, 5];
case 5: return [2 /*return*/];
}

@@ -99,0 +73,0 @@ });

@@ -34,18 +34,2 @@ /**

/**
* Checks whether given value's type is an undefined
* {@link isUndefined}.
*
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
export declare function isUndefined(wat: any): boolean;
/**
* Checks whether given value's type is a function
* {@link isFunction}.
*
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
export declare function isFunction(wat: any): boolean;
/**
* Checks whether given value's type is a string

@@ -67,10 +51,2 @@ * {@link isString}.

/**
* Checks whether given value's type is an array
* {@link isArray}.
*
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
export declare function isArray(wat: any): boolean;
/**
* Checks whether given value's type is an object literal

@@ -92,9 +68,6 @@ * {@link isPlainObject}.

/**
* Checks whether given value's type is a NaN
* {@link isNaN}.
*
* Checks whether given value has a then function.
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
export declare function isNaN(wat: any): boolean;
export declare function isThenable(wat: any): boolean;
/**

@@ -101,0 +74,0 @@ * Checks whether given value's type is a SyntheticEvent

@@ -57,24 +57,2 @@ "use strict";

/**
* Checks whether given value's type is an undefined
* {@link isUndefined}.
*
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
function isUndefined(wat) {
return wat === void 0;
}
exports.isUndefined = isUndefined;
/**
* Checks whether given value's type is a function
* {@link isFunction}.
*
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
function isFunction(wat) {
return typeof wat === 'function';
}
exports.isFunction = isFunction;
/**
* Checks whether given value's type is a string

@@ -102,13 +80,2 @@ * {@link isString}.

/**
* Checks whether given value's type is an array
* {@link isArray}.
*
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
function isArray(wat) {
return Object.prototype.toString.call(wat) === '[object Array]';
}
exports.isArray = isArray;
/**
* Checks whether given value's type is an object literal

@@ -136,12 +103,11 @@ * {@link isPlainObject}.

/**
* Checks whether given value's type is a NaN
* {@link isNaN}.
*
* Checks whether given value has a then function.
* @param wat A value to be checked.
* @returns A boolean representing the result.
*/
function isNaN(wat) {
return wat !== wat;
function isThenable(wat) {
// tslint:disable:no-unsafe-any
return Boolean(wat && wat.then && typeof wat.then === 'function');
// tslint:enable:no-unsafe-any
}
exports.isNaN = isNaN;
exports.isThenable = isThenable;
/**

@@ -148,0 +114,0 @@ * Checks whether given value's type is a SyntheticEvent

/** JSDoc */
declare class Logger {
/** JSDoc */
private enabled;
private _enabled;
/** JSDoc */

@@ -6,0 +6,0 @@ constructor();

@@ -6,2 +6,4 @@ "use strict";

var global = misc_1.getGlobalObject();
/** Prefix for logging strings */
var PREFIX = 'Sentry Logger ';
/** JSDoc */

@@ -11,11 +13,11 @@ var Logger = /** @class */ (function () {

function Logger() {
this.enabled = false;
this._enabled = false;
}
/** JSDoc */
Logger.prototype.disable = function () {
this.enabled = false;
this._enabled = false;
};
/** JSDoc */
Logger.prototype.enable = function () {
this.enabled = true;
this._enabled = true;
};

@@ -28,7 +30,7 @@ /** JSDoc */

}
if (!this.enabled) {
if (!this._enabled) {
return;
}
misc_1.consoleSandbox(function () {
global.console.log("Sentry Logger [Log]: " + args.join(' ')); // tslint:disable-line:no-console
global.console.log(PREFIX + "[Log]: " + args.join(' ')); // tslint:disable-line:no-console
});

@@ -42,7 +44,7 @@ };

}
if (!this.enabled) {
if (!this._enabled) {
return;
}
misc_1.consoleSandbox(function () {
global.console.warn("Sentry Logger [Warn]: " + args.join(' ')); // tslint:disable-line:no-console
global.console.warn(PREFIX + "[Warn]: " + args.join(' ')); // tslint:disable-line:no-console
});

@@ -56,7 +58,7 @@ };

}
if (!this.enabled) {
if (!this._enabled) {
return;
}
misc_1.consoleSandbox(function () {
global.console.error("Sentry Logger [Error]: " + args.join(' ')); // tslint:disable-line:no-console
global.console.error(PREFIX + "[Error]: " + args.join(' ')); // tslint:disable-line:no-console
});

@@ -63,0 +65,0 @@ };

@@ -6,5 +6,5 @@ /**

/** Determines if WeakSet is available */
private readonly hasWeakSet;
private readonly _hasWeakSet;
/** Either WeakSet or Array */
private readonly inner;
private readonly _inner;
constructor();

@@ -11,0 +11,0 @@ /**

@@ -10,4 +10,4 @@ "use strict";

// tslint:disable-next-line
this.hasWeakSet = typeof WeakSet === 'function';
this.inner = this.hasWeakSet ? new WeakSet() : [];
this._hasWeakSet = typeof WeakSet === 'function';
this._inner = this._hasWeakSet ? new WeakSet() : [];
}

@@ -19,20 +19,18 @@ /**

Memo.prototype.memoize = function (obj) {
if (this.hasWeakSet) {
if (this.inner.has(obj)) {
if (this._hasWeakSet) {
if (this._inner.has(obj)) {
return true;
}
this.inner.add(obj);
this._inner.add(obj);
return false;
}
else {
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < this.inner.length; i++) {
var value = this.inner[i];
if (value === obj) {
return true;
}
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < this._inner.length; i++) {
var value = this._inner[i];
if (value === obj) {
return true;
}
this.inner.push(obj);
return false;
}
this._inner.push(obj);
return false;
};

@@ -44,9 +42,9 @@ /**

Memo.prototype.unmemoize = function (obj) {
if (this.hasWeakSet) {
this.inner.delete(obj);
if (this._hasWeakSet) {
this._inner.delete(obj);
}
else {
for (var i = 0; i < this.inner.length; i++) {
if (this.inner[i] === obj) {
this.inner.splice(i, 1);
for (var i = 0; i < this._inner.length; i++) {
if (this._inner[i] === obj) {
this._inner.splice(i, 1);
break;

@@ -53,0 +51,0 @@ }

/// <reference types="node" />
import { SentryEvent } from '@sentry/types';
import { Event, Mechanism } from '@sentry/types';
/**
* Requires a module which is protected against bundler minification.
* Requires a module which is protected _against bundler minification.
*

@@ -57,4 +57,13 @@ * @param request The module path to resolve

*/
export declare function getEventDescription(event: SentryEvent): string;
export declare function getEventDescription(event: Event): string;
/** JSDoc */
export declare function consoleSandbox(callback: () => any): any;
/**
* Adds exception values, type and value to an synthetic Exception.
* @param event The event to modify.
* @param value Value of the exception.
* @param type Type of the exception.
* @param mechanism Mechanism of the exception.
* @hidden
*/
export declare function addExceptionTypeValue(event: Event, value?: string, type?: string, mechanism?: Mechanism): void;

@@ -5,3 +5,3 @@ "use strict";

/**
* Requires a module which is protected against bundler minification.
* Requires a module which is protected _against bundler minification.
*

@@ -68,12 +68,10 @@ * @param request The module path to resolve

}
else {
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
// tslint:disable-next-line:no-bitwise
var r = (Math.random() * 16) | 0;
// tslint:disable-next-line:no-bitwise
var v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
// tslint:disable-next-line:no-bitwise
var r = (Math.random() * 16) | 0;
// tslint:disable-next-line:no-bitwise
var v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}

@@ -184,3 +182,3 @@ exports.uuid4 = uuid4;

}
else if (event.exception && event.exception.values && event.exception.values[0]) {
if (event.exception && event.exception.values && event.exception.values[0]) {
var exception = event.exception.values[0];

@@ -190,9 +188,5 @@ if (exception.type && exception.value) {

}
else {
return exception.type || exception.value || event.event_id || '<unknown>';
}
return exception.type || exception.value || event.event_id || '<unknown>';
}
else {
return event.event_id || '<unknown>';
}
return event.event_id || '<unknown>';
}

@@ -225,2 +219,23 @@ exports.getEventDescription = getEventDescription;

exports.consoleSandbox = consoleSandbox;
/**
* Adds exception values, type and value to an synthetic Exception.
* @param event The event to modify.
* @param value Value of the exception.
* @param type Type of the exception.
* @param mechanism Mechanism of the exception.
* @hidden
*/
function addExceptionTypeValue(event, value, type, mechanism) {
if (mechanism === void 0) { mechanism = {
handled: true,
type: 'generic',
}; }
event.exception = event.exception || {};
event.exception.values = event.exception.values || [];
event.exception.values[0] = event.exception.values[0] || {};
event.exception.values[0].value = event.exception.values[0].value || value || '';
event.exception.values[0].type = event.exception.values[0].type || type || 'Error';
event.exception.values[0].mechanism = event.exception.values[0].mechanism || mechanism;
}
exports.addExceptionTypeValue = addExceptionTypeValue;
//# sourceMappingURL=misc.js.map
import { Memo } from './memo';
/**
* Serializes the given object into a string.
* Like JSON.stringify, but doesn't throw on circular references.
*
* @param object A JSON-serializable object.
* @returns A string containing the serialized object.
*/
export declare function serialize<T>(object: T): string;
/**
* Deserializes an object from a string previously serialized with
* {@link serialize}.
*
* @param str A serialized object.
* @returns The deserialized object.
*/
export declare function deserialize<T>(str: string): T;
/**
* Creates a deep copy of the given object.
*
* The object must be serializable, i.e.:
* - It must not contain any cycles
* - Only primitive types are allowed (object, array, number, string, boolean)
* - Its depth should be considerably low for performance reasons
*
* @param object A JSON-serializable object.
* @returns The object clone.
*/
export declare function clone<T>(object: T): T;
/**
* Wrap a given object method with a higher-order function

@@ -51,23 +23,26 @@ *

/** JSDoc */
export declare function serializeObject<T>(value: T, depth: number): T | string | {};
/** JSDoc */
export declare function limitObjectDepthToSize<T>(object: {
export declare function normalizeToSize<T>(object: {
[key: string]: any;
}, depth?: number, maxSize?: number): T;
/** JSDoc */
export declare function serializeKeysToEventMessage(keys: string[], maxLength?: number): string;
/** JSDoc */
export declare function assign(target: any, ...args: any[]): object;
/**
* Decycles an object to make it safe for json serialization.
* Walks an object to perform a normalization on it
*
* @param obj Object to be decycled
* @param key of object that's walked in current iteration
* @param value object to be walked
* @param depth Optional number indicating how deep should walking be performed
* @param memo Optional Memo class handling decycling
*/
export declare function decycle(obj: any, depth?: number, memo?: Memo): any;
export declare function walk(key: string, value: any, depth?: number, memo?: Memo): any;
/**
* safeNormalize()
* normalize()
*
* Creates a copy of the input by applying serializer function on it and parsing it back to unify the data
* - Creates a copy to prevent original input mutation
* - Skip non-enumerablers
* - Calls `toJSON` if implemented
* - Removes circular references
* - Translates non-serializeable values (undefined/NaN/Functions) to serializable format
* - Translates known global objects/Classes to a string representations
* - Takes care of Error objects serialization
* - Optionally limit depth of final output
*/
export declare function safeNormalize(input: any, depth?: number): any;
export declare function normalize(input: any, depth?: number): any;

@@ -5,41 +5,3 @@ "use strict";

var memo_1 = require("./memo");
var string_1 = require("./string");
/**
* Serializes the given object into a string.
* Like JSON.stringify, but doesn't throw on circular references.
*
* @param object A JSON-serializable object.
* @returns A string containing the serialized object.
*/
function serialize(object) {
return JSON.stringify(object, serializer({ normalize: false }));
}
exports.serialize = serialize;
/**
* Deserializes an object from a string previously serialized with
* {@link serialize}.
*
* @param str A serialized object.
* @returns The deserialized object.
*/
function deserialize(str) {
return JSON.parse(str);
}
exports.deserialize = deserialize;
/**
* Creates a deep copy of the given object.
*
* The object must be serializable, i.e.:
* - It must not contain any cycles
* - Only primitive types are allowed (object, array, number, string, boolean)
* - Its depth should be considerably low for performance reasons
*
* @param object A JSON-serializable object.
* @returns The object clone.
*/
function clone(object) {
return deserialize(serialize(object));
}
exports.clone = clone;
/**
* Wrap a given object method with a higher-order function

@@ -95,112 +57,2 @@ *

exports.urlEncode = urlEncode;
// Default Node.js REPL depth
var MAX_SERIALIZE_EXCEPTION_DEPTH = 3;
// 100kB, as 200kB is max payload size, so half sounds reasonable
var MAX_SERIALIZE_EXCEPTION_SIZE = 100 * 1024;
var MAX_SERIALIZE_KEYS_LENGTH = 40;
/** JSDoc */
function utf8Length(value) {
// tslint:disable-next-line:no-bitwise
return ~-encodeURI(value).split(/%..|./).length;
}
/** JSDoc */
function jsonSize(value) {
return utf8Length(JSON.stringify(value));
}
/** JSDoc */
function serializeValue(value) {
var type = Object.prototype.toString.call(value);
// Node.js REPL notation
if (typeof value === 'string') {
return string_1.truncate(value, 40);
}
else if (type === '[object Object]') {
return '[Object]';
}
else if (type === '[object Array]') {
return '[Array]';
}
else {
var normalized = normalizeValue(value);
return is_1.isPrimitive(normalized) ? "" + normalized : type;
}
}
/** JSDoc */
function serializeObject(value, depth) {
if (depth === 0) {
return serializeValue(value);
}
if (is_1.isPlainObject(value)) {
var serialized_1 = {};
var val_1 = value;
Object.keys(val_1).forEach(function (key) {
serialized_1[key] = serializeObject(val_1[key], depth - 1);
});
return serialized_1;
}
else if (is_1.isArray(value)) {
var val = value;
return val.map(function (v) { return serializeObject(v, depth - 1); });
}
return serializeValue(value);
}
exports.serializeObject = serializeObject;
/** JSDoc */
function limitObjectDepthToSize(object, depth, maxSize) {
if (depth === void 0) { depth = MAX_SERIALIZE_EXCEPTION_DEPTH; }
if (maxSize === void 0) { maxSize = MAX_SERIALIZE_EXCEPTION_SIZE; }
var serialized = serializeObject(object, depth);
if (jsonSize(serialize(serialized)) > maxSize) {
return limitObjectDepthToSize(object, depth - 1);
}
return serialized;
}
exports.limitObjectDepthToSize = limitObjectDepthToSize;
/** JSDoc */
function serializeKeysToEventMessage(keys, maxLength) {
if (maxLength === void 0) { maxLength = MAX_SERIALIZE_KEYS_LENGTH; }
if (!keys.length) {
return '[object has no keys]';
}
if (keys[0].length >= maxLength) {
return string_1.truncate(keys[0], maxLength);
}
for (var includedKeys = keys.length; includedKeys > 0; includedKeys--) {
var serialized = keys.slice(0, includedKeys).join(', ');
if (serialized.length > maxLength) {
continue;
}
if (includedKeys === keys.length) {
return serialized;
}
return string_1.truncate(serialized, maxLength);
}
return '';
}
exports.serializeKeysToEventMessage = serializeKeysToEventMessage;
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
/** JSDoc */
function assign(target) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (target === null || target === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
// tslint:disable-next-line:prefer-for-of
for (var i = 0; i < args.length; i++) {
var source = args[i];
if (source !== null) {
for (var nextKey in source) {
if (Object.prototype.hasOwnProperty.call(source, nextKey)) {
to[nextKey] = source[nextKey];
}
}
}
}
return to;
}
exports.assign = assign;
/**

@@ -229,2 +81,42 @@ * Transforms Error object into an object literal with all it's attributes

}
/** Calculates bytes size of input string */
function utf8Length(value) {
// tslint:disable-next-line:no-bitwise
return ~-encodeURI(value).split(/%..|./).length;
}
/** Calculates bytes size of input object */
function jsonSize(value) {
return utf8Length(JSON.stringify(value));
}
/** JSDoc */
function normalizeToSize(object,
// Default Node.js REPL depth
depth,
// 100kB, as 200kB is max payload size, so half sounds reasonable
maxSize) {
if (depth === void 0) { depth = 3; }
if (maxSize === void 0) { maxSize = 100 * 1024; }
var serialized = normalize(object, depth);
if (jsonSize(serialized) > maxSize) {
return normalizeToSize(object, depth - 1, maxSize);
}
return serialized;
}
exports.normalizeToSize = normalizeToSize;
/** Transforms any input value into a string form, either primitive value or a type of the input */
function serializeValue(value) {
var type = Object.prototype.toString.call(value);
// Node.js REPL notation
if (typeof value === 'string') {
return value;
}
if (type === '[object Object]') {
return '[Object]';
}
if (type === '[object Array]') {
return '[Array]';
}
var normalized = normalizeValue(value);
return is_1.isPrimitive(normalized) ? normalized : type;
}
/**

@@ -263,6 +155,6 @@ * normalizeValue()

}
if (is_1.isNaN(value)) {
if (Number.isNaN(value)) {
return '[NaN]';
}
if (is_1.isUndefined(value)) {
if (value === void 0) {
return '[undefined]';

@@ -276,57 +168,66 @@ }

/**
* Decycles an object to make it safe for json serialization.
* Walks an object to perform a normalization on it
*
* @param obj Object to be decycled
* @param key of object that's walked in current iteration
* @param value object to be walked
* @param depth Optional number indicating how deep should walking be performed
* @param memo Optional Memo class handling decycling
*/
function decycle(obj, depth, memo) {
function walk(key, value, depth, memo) {
if (depth === void 0) { depth = +Infinity; }
if (memo === void 0) { memo = new memo_1.Memo(); }
// If we reach the maximum depth, serialize whatever has left
if (depth === 0) {
return serializeValue(obj);
return serializeValue(value);
}
// If an object was normalized to its string form, we should just bail out as theres no point in going down that branch
var normalized = normalizeValue(obj);
// If value implements `toJSON` method, call it and return early
// tslint:disable:no-unsafe-any
if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
return value.toJSON();
}
// tslint:enable:no-unsafe-any
// If normalized value is a primitive, there are no branches left to walk, so we can just bail out, as theres no point in going down that branch any further
var normalized = normalizeValue(value, key);
if (is_1.isPrimitive(normalized)) {
return normalized;
}
// tslint:disable-next-line:no-unsafe-any
var source = (is_1.isError(obj) ? objectifyError(obj) : obj);
var copy = is_1.isArray(obj) ? [] : {};
if (memo.memoize(obj)) {
// Create source that we will use for next itterations, either objectified error object (Error type with extracted keys:value pairs) or the input itself
var source = (is_1.isError(value) ? objectifyError(value) : value);
// Create an accumulator that will act as a parent for all future itterations of that branch
var acc = Array.isArray(value) ? [] : {};
// If we already walked that branch, bail out, as it's circular reference
if (memo.memoize(value)) {
return '[Circular ~]';
}
for (var key in source) {
// Walk all keys of the source
for (var innerKey in source) {
// Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
if (!Object.prototype.hasOwnProperty.call(source, key)) {
if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
continue;
}
copy[key] = decycle(source[key], depth - 1, memo);
// Recursively walk through all the child nodes
acc[innerKey] = walk(innerKey, source[innerKey], depth - 1, memo);
}
memo.unmemoize(obj);
return copy;
// Once walked through all the branches, remove the parent from memo storage
memo.unmemoize(value);
// Return accumulated values
return acc;
}
exports.decycle = decycle;
exports.walk = walk;
/**
* serializer()
* normalize()
*
* Remove circular references,
* translates undefined/NaN values to "[undefined]"/"[NaN]" respectively,
* and takes care of Error objects serialization
* - Creates a copy to prevent original input mutation
* - Skip non-enumerablers
* - Calls `toJSON` if implemented
* - Removes circular references
* - Translates non-serializeable values (undefined/NaN/Functions) to serializable format
* - Translates known global objects/Classes to a string representations
* - Takes care of Error objects serialization
* - Optionally limit depth of final output
*/
function serializer(options) {
if (options === void 0) { options = { normalize: true }; }
return function (key, value) {
// tslint:disable-next-line
return options.normalize ? normalizeValue(decycle(value, options.depth), key) : decycle(value, options.depth);
};
}
/**
* safeNormalize()
*
* Creates a copy of the input by applying serializer function on it and parsing it back to unify the data
*/
function safeNormalize(input, depth) {
function normalize(input, depth) {
try {
return JSON.parse(JSON.stringify(input, serializer({ normalize: true, depth: depth })));
// tslint:disable-next-line:no-unsafe-any
return JSON.parse(JSON.stringify(input, function (key, value) { return walk(key, value, depth); }));
}

@@ -337,3 +238,3 @@ catch (_oO) {

}
exports.safeNormalize = safeNormalize;
exports.normalize = normalize;
//# sourceMappingURL=object.js.map
{
"name": "@sentry/utils",
"version": "4.6.4",
"version": "5.0.0-rc.0",
"description": "Utilities for all Sentry JavaScript SDKs",

@@ -16,3 +16,3 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"dependencies": {
"@sentry/types": "4.5.3",
"@sentry/types": "5.0.0-rc.0",
"tslib": "^1.9.3"

@@ -22,18 +22,16 @@ },

"chai": "^4.1.2",
"jest": "^22.4.3",
"jest": "^24.5.0",
"npm-run-all": "^4.1.2",
"prettier": "^1.14.0",
"prettier": "^1.16.4",
"prettier-check": "^2.0.0",
"rimraf": "^2.6.2",
"tslint": "^5.11.0",
"typescript": "^3.2.0"
"rimraf": "^2.6.3",
"tslint": "^5.14.0",
"typescript": "^3.3.3333"
},
"scripts": {
"build": "run-s clean && run-p build:es5 build:esm",
"build": "run-s clean && run-p build:es5",
"build:es5": "tsc -p tsconfig.build.json",
"build:esm": "run-s build:esm:transpile build:esm:rewrite",
"build:esm:transpile": "tsc -p tsconfig.esm.json",
"build:esm:rewrite": "node ../../scripts/esm-rewrite.js",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage *.js *.js.map *.d.ts",
"clean": "rimraf dist esm coverage *.js *.js.map *.d.ts",
"link:yarn": "yarn link",
"lint": "run-s lint:prettier lint:tslint",

@@ -47,3 +45,3 @@ "lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",

"test": "jest",
"test:watch": "jest --watch --notify"
"test:watch": "jest --watch"
},

@@ -50,0 +48,0 @@ "jest": {

@@ -8,9 +8,9 @@ /**

/** Internal path for JSON file. */
private readonly path;
private readonly _path;
/** Value used to initialize data for the first time. */
private readonly initial;
private readonly _initial;
/** Current state of the data. */
private data?;
private _data?;
/** State whether a flush to disk has been requested in this cycle. */
private flushing;
private _flushing;
/**

@@ -45,3 +45,3 @@ * Creates a new store.

/** Serializes the current data into the JSON file. */
private flush;
private _flush;
}

@@ -20,5 +20,5 @@ "use strict";

function Store(path, id, initial) {
this.path = path_1.join(path, id + ".json");
this.initial = initial;
this.flushing = false;
this._path = path_1.join(path, id + ".json");
this._initial = initial;
this._flushing = false;
}

@@ -31,7 +31,7 @@ /**

var _this = this;
this.data = next;
if (!this.flushing) {
this.flushing = true;
this._data = next;
if (!this._flushing) {
this._flushing = true;
setImmediate(function () {
_this.flush();
_this._flush();
});

@@ -55,21 +55,21 @@ }

Store.prototype.get = function () {
if (this.data === undefined) {
if (this._data === undefined) {
try {
this.data = fs_1.existsSync(this.path) ? JSON.parse(fs_1.readFileSync(this.path, 'utf8')) : this.initial;
this._data = fs_1.existsSync(this._path) ? JSON.parse(fs_1.readFileSync(this._path, 'utf8')) : this._initial;
}
catch (e) {
this.data = this.initial;
this._data = this._initial;
}
}
return this.data;
return this._data;
};
/** Returns store to its initial state */
Store.prototype.clear = function () {
this.set(this.initial);
this.set(this._initial);
};
/** Serializes the current data into the JSON file. */
Store.prototype.flush = function () {
Store.prototype._flush = function () {
try {
fs_2.mkdirpSync(path_1.dirname(this.path));
fs_1.writeFileSync(this.path, JSON.stringify(this.data));
fs_2.mkdirpSync(path_1.dirname(this._path));
fs_1.writeFileSync(this._path, JSON.stringify(this._data));
}

@@ -82,3 +82,3 @@ catch (e) {

finally {
this.flushing = false;
this._flushing = false;
}

@@ -85,0 +85,0 @@ };

@@ -25,9 +25,3 @@ /**

export declare function safeJoin(input: any[], delimiter?: string): string;
/**
* Checks if given value is included in the target
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
* @param target source string
* @param search string to be looked for
* @returns An answer
*/
export declare function includes(target: string, search: string): boolean;
/** Merges provided array of keys into */
export declare function keysToEventMessage(keys: string[], maxLength?: number): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var is_1 = require("./is");
/**

@@ -13,3 +12,3 @@ * Truncates given string to the maximum characters count

if (max === void 0) { max = 0; }
if (max === 0 || !is_1.isString(str)) {
if (max === 0) {
return str;

@@ -82,18 +81,24 @@ }

exports.safeJoin = safeJoin;
/**
* Checks if given value is included in the target
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
* @param target source string
* @param search string to be looked for
* @returns An answer
*/
function includes(target, search) {
if (search.length > target.length) {
return false;
/** Merges provided array of keys into */
function keysToEventMessage(keys, maxLength) {
if (maxLength === void 0) { maxLength = 40; }
if (!keys.length) {
return '[object has no keys]';
}
else {
return target.indexOf(search) !== -1;
if (keys[0].length >= maxLength) {
return truncate(keys[0], maxLength);
}
for (var includedKeys = keys.length; includedKeys > 0; includedKeys--) {
var serialized = keys.slice(0, includedKeys).join(', ');
if (serialized.length > maxLength) {
continue;
}
if (includedKeys === keys.length) {
return serialized;
}
return truncate(serialized, maxLength);
}
return '';
}
exports.includes = includes;
exports.keysToEventMessage = keysToEventMessage;
//# sourceMappingURL=string.js.map

@@ -136,3 +136,3 @@ "use strict";

// tslint:disable:no-unused-expression
new Request('pickleRick', {
new Request('_', {
referrerPolicy: 'origin',

@@ -139,0 +139,0 @@ });

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

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