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

@sentry/utils

Package Overview
Dependencies
Maintainers
9
Versions
517
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.0.0-beta.6 to 4.0.0-beta.7

8

fs.d.ts
/**
* Asynchronously creates the given directory.
*
* @param path A relative or absolute path to the directory.
* @param mode The permission mode.
* @returns A Promise that resolves when the path has been created.
*/
export declare function readFileAsync(path: string): Promise<Error | string>;
/**
* Recursively creates the given path.

@@ -3,0 +11,0 @@ *

@@ -48,2 +48,28 @@ "use strict";

*/
function readFileAsync(path) {
return __awaiter(this, void 0, void 0, function () {
return __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.
*
* @param path A relative or absolute path to the directory.
* @param mode The permission mode.
* @returns A Promise that resolves when the path has been created.
*/
function mkdirAsync(path, mode) {

@@ -50,0 +76,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -33,1 +33,9 @@ /**

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

@@ -56,2 +56,13 @@ "use strict";

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

@@ -58,1 +58,11 @@ /**

}): string;
/**
* TODO
*/
export declare function limitObjectDepthToSize<T>(object: {
[key: string]: any;
}, depth?: number, maxSize?: number): T;
/**
* TODO
*/
export declare function serializeKeysToEventMessage(keys: string[], maxLength?: number): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var is_1 = require("./is");
/**

@@ -140,2 +141,109 @@ * Transforms Error object into an object literal with all it's attributes

exports.urlEncode = urlEncode;
// Default Node.js REPL depth
var MAX_SERIALIZE_EXCEPTION_DEPTH = 3;
// TODO: Or is it 200kb? 🤔 — Kamil
// 50kB, as 100kB is max payload size, so half sounds reasonable
var MAX_SERIALIZE_EXCEPTION_SIZE = 50 * 1024;
var MAX_SERIALIZE_KEYS_LENGTH = 40;
/**
* TODO
*/
function utf8Length(value) {
// tslint:disable-next-line:no-bitwise
return ~-encodeURI(value).split(/%..|./).length;
}
/**
* TODO
*/
function jsonSize(value) {
return utf8Length(JSON.stringify(value));
}
/**
* TODO
*/
function serializeValue(value) {
var maxLength = 40;
if (typeof value === 'string') {
return value.length <= maxLength
? value
: value.substr(0, maxLength - 1) + "\u2026";
}
else if (typeof value === 'number' ||
typeof value === 'boolean' ||
typeof value === 'undefined') {
return value;
}
var type = Object.prototype.toString.call(value);
// Node.js REPL notation
if (type === '[object Object]') {
return '[Object]';
}
if (type === '[object Array]') {
return '[Array]';
}
if (type === '[object Function]') {
var name_1 = value.name;
return name_1 ? "[Function: " + name_1 + "]" : '[Function]';
}
return value;
}
/**
* TODO
*/
function serializeObject(value, depth) {
return value;
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 (Array.isArray(value)) {
var val = value;
return val.map(function (v) { return serializeObject(v, depth - 1); });
}
return serializeValue(value);
}
/**
* TODO
*/
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;
/**
* TODO
*/
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 keys[0];
}
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 serialized + "\u2026";
}
return '';
}
exports.serializeKeysToEventMessage = serializeKeysToEventMessage;
//# sourceMappingURL=object.js.map

10

package.json
{
"name": "@sentry/utils",
"version": "4.0.0-beta.6",
"version": "4.0.0-beta.7",
"description": "Utilities for all Sentry JavaScript SDKs",

@@ -16,3 +16,3 @@ "repository": "git://github.com/getsentry/raven-js.git",

"dependencies": {
"@sentry/types": "4.0.0-beta.6"
"@sentry/types": "4.0.0-beta.7"
},

@@ -27,7 +27,7 @@ "devDependencies": {

"tslint": "^5.9.1",
"typescript": "^2.8.3"
"typescript": "^2.9.2"
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"build": "run-s clean; tsc -p tsconfig.build.json",
"build:watch": "run-s clean; tsc -p tsconfig.build.json -w --preserveWatchOutput",
"clean": "rimraf dist coverage *.js *.js.map *.d.ts",

@@ -34,0 +34,0 @@ "lint": "run-s lint:prettier lint:tslint",

@@ -9,1 +9,10 @@ /**

export declare function truncate(str: string, max: number): string;
/**
* This is basically just `trim_line` from
* https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67
*
* @param str An object that contains serializable values
* @param max Maximum number of characters in truncated string
* @returns string Encoded
*/
export declare function snipLine(line: string, colno: number): string;

@@ -17,2 +17,40 @@ "use strict";

exports.truncate = truncate;
/**
* This is basically just `trim_line` from
* https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67
*
* @param str An object that contains serializable values
* @param max Maximum number of characters in truncated string
* @returns string Encoded
*/
function snipLine(line, colno) {
var newLine = line;
var ll = newLine.length;
if (ll <= 150) {
return newLine;
}
if (colno > ll) {
colno = ll; // tslint:disable-line:no-parameter-reassignment
}
var start = Math.max(colno - 60, 0);
if (start < 5) {
start = 0;
}
var end = Math.min(start + 140, ll);
if (end > ll - 5) {
end = ll;
}
if (end === ll) {
start = Math.max(end - 140, 0);
}
newLine = newLine.slice(start, end);
if (start > 0) {
newLine = "'{snip} " + newLine;
}
if (end < ll) {
newLine += ' {snip}';
}
return newLine;
}
exports.snipLine = snipLine;
//# sourceMappingURL=string.js.map

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