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

blork

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blork - npm Package Compare versions

Comparing version 9.2.2 to 9.3.0

.github/workflows/ci.yaml

2

lib/add.js

@@ -33,3 +33,3 @@ const BlorkError = require("./errors/BlorkError");

// Save the checker and save desc to it.
const created = v => found(v);
const created = (v) => found(v);
checkers[name] = created;

@@ -36,0 +36,0 @@ created.desc = description || name;

@@ -21,3 +21,3 @@ const BlorkError = require("./errors/BlorkError");

// Return checker.
return v => checker(v);
return (v) => checker(v);
}

@@ -24,0 +24,0 @@

@@ -14,5 +14,5 @@ // Types.

// Functions.
export declare function check(value: any, type: string, error?: Function): void;
export declare function check(value: any, type: string, error?: typeof ValueError | { new (message: string): any }): void;
export declare function checker(type: string): BlorkChecker;
export declare function add(name: string, checker: string | BlorkChecker, description?: string): void;
export declare function debug(value: any): string;

@@ -66,3 +66,3 @@ // Constants.

// Append each new line to the string.
rows.push(debugInternal(value[i], tabs + "\t", stack));
rows.push(debugInternal(value[i], `${tabs}\t`, stack));
}

@@ -76,3 +76,3 @@

return rows.reduce((t, v) => t + v.length, 0) > MULTILINE_CHARS
? `[\n\t${tabs}${rows.join(",\n\t" + tabs)}\n${tabs}]` // Multiline.
? `[\n\t${tabs}${rows.join(`,\n\t${tabs}`)}\n${tabs}]` // Multiline.
: `[${rows.join(", ")}]`; // Single line.

@@ -88,4 +88,4 @@ } else {

: value.constructor instanceof Function && value.constructor.name.length
? `${value.constructor.name} `
: "anonymous object ";
? `${value.constructor.name} `
: "anonymous object ";

@@ -109,3 +109,3 @@ // Empty object, e.g. {}

const key = keys[i];
rows.push(`${debugString(key)}: ${debugInternal(value[key], tabs + "\t", stack)}`);
rows.push(`${debugString(key)}: ${debugInternal(value[key], `${tabs}\t`, stack)}`);
}

@@ -119,3 +119,3 @@

return rows.reduce((t, v) => t + v.length, 0) > MULTILINE_CHARS
? `${name}{\n\t${tabs}${rows.join(",\n\t" + tabs)}\n${tabs}}` // Multiline.
? `${name}{\n\t${tabs}${rows.join(`,\n\t${tabs}`)}\n${tabs}}` // Multiline.
: `${name}{ ${rows.join(", ")} }`; // Single line.

@@ -133,3 +133,3 @@ }

// Reduce to under 200 chars.
if (value.length > MAX_CHARS) value = value.substr(0, MAX_CHARS) + "…";
if (value.length > MAX_CHARS) value = `${value.substr(0, MAX_CHARS)}…`;
// Escape double quotes.

@@ -157,3 +157,3 @@ value = value.replace(/"/g, '\\"');

const name = value.name || value.constructor.name;
const message = value.message;
const { message } = value;
if (message) return `${name} ${debugString(value.message)}`;

@@ -160,0 +160,0 @@ else return name;

@@ -16,7 +16,7 @@ // List of function and file names we blank out (for consistency).

return {
function: FUNCS.indexOf(matches[1]) >= 0 ? "" : matches[1] + "()",
function: FUNCS.indexOf(matches[1]) >= 0 ? "" : `${matches[1]}()`,
file: FILES.indexOf(matches[2]) >= 0 ? "" : matches[2],
line: matches[3] !== undefined ? parseInt(matches[3], 10) : null,
column: matches[4] !== undefined ? parseInt(matches[4], 10) : null,
original: matches[0]
original: matches[0],
};

@@ -30,6 +30,6 @@ } else {

column: matches[7] !== undefined ? parseInt(matches[7], 10) : null,
original: matches[0]
original: matches[0],
};
}
}
},
},

@@ -42,10 +42,10 @@ // Firefox, Safari.

return {
function: FUNCS.indexOf(matches[1]) >= 0 ? "" : matches[1] + "()",
function: FUNCS.indexOf(matches[1]) >= 0 ? "" : `${matches[1]}()`,
file: FILES.indexOf(matches[2]) >= 0 ? "" : matches[2],
line: typeof matches[3] !== "undefined" ? parseInt(matches[3], 10) : null,
column: typeof matches[4] !== "undefined" ? parseInt(matches[4], 10) : null,
original: matches[0]
original: matches[0],
};
}
}
},
},
];

@@ -52,0 +52,0 @@

@@ -18,3 +18,3 @@ const modifyChecker = require("./modifyChecker");

// Try to create the checker.
const checker = modifyChecker(modifiers, type, t => findChecker(checkers, modifiers, t));
const checker = modifyChecker(modifiers, type, (t) => findChecker(checkers, modifiers, t));
if (checker) {

@@ -21,0 +21,0 @@ checkers[type] = checker;

@@ -30,3 +30,3 @@ const debug = require("../helpers/debug");

// Create a checker.
const checker = v => valueChecker(v);
const checker = (v) => valueChecker(v);

@@ -39,3 +39,3 @@ // Checker settings.

return checker;
}
},
},

@@ -55,3 +55,3 @@

// Create a checker.
const checker = v => valueChecker(v);
const checker = (v) => valueChecker(v);

@@ -64,3 +64,3 @@ // Checker settings.

return checker;
}
},
},

@@ -74,3 +74,3 @@

// Convert matches to types.
const length = types.length;
const { length } = types;
const checkers = types.map(find);

@@ -82,3 +82,3 @@

// Check each checker.
const checker = v => {
const checker = (v) => {
// Loop through and call each checker.

@@ -92,3 +92,3 @@ for (let i = 0; i < length; i++) if (!checkers[i](v)) return false; // Fail.

// Get checker descriptions and wrap any that have been modified.
.map(c => wrapModified(c))
.map((c) => wrapModified(c))
// Join them with " and "

@@ -101,3 +101,3 @@ .join(" and ");

return checker;
}
},
},

@@ -111,3 +111,3 @@

// Convert matches to types.
const length = types.length;
const { length } = types;
const checkers = types.map(find);

@@ -119,3 +119,3 @@

// Check each checker.
const checker = v => {
const checker = (v) => {
// Loop through and call each checker.

@@ -129,3 +129,3 @@ for (let i = 0; i < length; i++) if (checkers[i](v)) return true; // Pass.

// Get checker descriptions and wrap any that have been modified.
.map(c => wrapModified(c))
.map((c) => wrapModified(c))
// Join them with " and "

@@ -138,3 +138,3 @@ .join(" or ");

return checker;
}
},
},

@@ -149,3 +149,3 @@

// Create a checker.
const checker = v => typeof v === "string" && v === type;
const checker = (v) => typeof v === "string" && v === type;

@@ -158,3 +158,3 @@ // Checker settings.

return checker;
}
},
},

@@ -169,3 +169,3 @@

// Create a checker.
const checker = v => typeof v === "string" && v === type;
const checker = (v) => typeof v === "string" && v === type;

@@ -178,3 +178,3 @@ // Checker settings.

return checker;
}
},
},

@@ -195,3 +195,3 @@

// Create a checker.
const checker = v => valueChecker(v);
const checker = (v) => valueChecker(v);

@@ -205,3 +205,3 @@ // Checker settings.

return checker;
}
},
},

@@ -222,3 +222,3 @@

// Create array type checker.
const checker = v => {
const checker = (v) => {
// Must be an array.

@@ -228,3 +228,3 @@ if (!isArray(v)) return false;

// Check every item in the array matches type.
return v.every(w => valueChecker(w));
return v.every((w) => valueChecker(w));
};

@@ -238,3 +238,3 @@

return checker;
}
},
},

@@ -254,3 +254,3 @@

const checkers = types.map(find);
const length = checkers.length;
const { length } = checkers;

@@ -261,3 +261,3 @@ // Checkers must exist.

// Create array type checker.
const checker = v => {
const checker = (v) => {
// Must be an array.

@@ -275,3 +275,3 @@ if (!isArray(v)) return false;

// Map checker descriptions.
const descs = checkers.map(c => c.desc);
const descs = checkers.map((c) => c.desc);

@@ -284,3 +284,3 @@ // Checker settings.

return checker;
}
},
},

@@ -306,3 +306,3 @@

// Loop through to create list of named and any checkers.
types.forEach(t => {
types.forEach((t) => {
// Split into key: value.

@@ -339,3 +339,3 @@ const kv = unnestedSplit(t, ":");

// Create array type checker.
const checker = v => {
const checker = (v) => {
// Must be an array.

@@ -373,4 +373,4 @@ if (!objectChecker(v)) return false;

// Descriptions.
const namedDescs = namedKeys.map(k => `${debug(k)}: ${wrapCombined(namedCheckers[k])}`);
const anyDescs = anyCheckers.map(c => {
const namedDescs = namedKeys.map((k) => `${debug(k)}: ${wrapCombined(namedCheckers[k])}`);
const anyDescs = anyCheckers.map((c) => {
// Key and value check or key only check.

@@ -388,3 +388,3 @@ if (c[0]) return `${wrapCombined(c[0])}: ${wrapCombined(c[1])}`;

return checker;
}
},
},

@@ -405,3 +405,3 @@

// Returns 0 if undefined, or passes through to the normal checker.
const checker = v => !valueChecker(v);
const checker = (v) => !valueChecker(v);

@@ -414,3 +414,3 @@ // Checker settings.

return checker;
}
},
},

@@ -431,3 +431,3 @@

// Returns 0 if undefined, or passes through to the normal checker.
const checker = v => (v === undefined ? true : valueChecker(v));
const checker = (v) => (v === undefined ? true : valueChecker(v));

@@ -441,3 +441,3 @@ // Checker settings.

return checker;
}
},
},

@@ -459,3 +459,3 @@

// Returns true if checker passes and there's a numeric length or size property with a value of >0.
const checker = v => {
const checker = (v) => {
// Must pass the checker first.

@@ -473,3 +473,3 @@ if (!valueChecker(v)) return false;

return checker;
}
},
},

@@ -486,3 +486,3 @@

// Create a checker.
const checker = v => typeof v === "number" && v === number;
const checker = (v) => typeof v === "number" && v === number;

@@ -495,3 +495,3 @@ // Checker settings.

return checker;
}
},
},

@@ -518,9 +518,9 @@

: matches[4]
? parseInt(matches[4], 10)
: matches[5]
? parseInt(matches[5])
: null;
? parseInt(matches[4], 10)
: matches[5]
? parseInt(matches[5])
: null;
// Create a length checker for this type.
const checker = v => {
const checker = (v) => {
// Must pass the checker first.

@@ -556,4 +556,4 @@ if (!valueChecker(v)) return false;

return checker;
}
}
},
},
];
{
"name": "blork",
"description": "Blork! Mini runtime type checking in Javascript",
"version": "9.2.2",
"version": "9.3.0",
"license": "0BSD",

@@ -10,4 +10,3 @@ "author": "Dave Houlbrooke <dave@shax.com>",

"engines": {
"node": ">=8.0.0",
"yarn": ">=1.0.0"
"node": ">=10.0.0"
},

@@ -18,27 +17,16 @@ "repository": {

},
"dependencies": {},
"devDependencies": {
"commitlint": "^7.2.1",
"eslint": "^5.7.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.0.0",
"husky": "^1.1.2",
"jest": "^23.6.0",
"prettier": "^1.10.2",
"semantic-release": "^15.10.5"
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"jest": "^26.6.3",
"prettier": "^2.2.1"
},
"scripts": {
"watch": "jest --watchAll",
"jest": "jest --coverage",
"lint": "eslint ./",
"fix": "eslint --fix ./",
"test": "yarn lint && yarn jest",
"publish": "semantic-release"
"test": "npm run test:eslint && npm run test:jest",
"test:eslint": "eslint ./",
"test:jest": "jest --coverage",
"test:jest:watch": "jest --watchAll"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "yarn test"
}
},
"eslintConfig": {

@@ -79,3 +67,18 @@ "parserOptions": {

"strict": 2,
"valid-jsdoc": 2
"valid-jsdoc": 2,
"no-prototype-builtins": 0,
"no-else-return": 0,
"func-names": 0,
"prefer-rest-params": 0,
"no-new-wrappers": 0,
"symbol-description": 0,
"no-nested-ternary": 0,
"consistent-return": 0,
"radix": 0,
"no-param-reassign": 0,
"class-methods-use-this": 0,
"no-use-before-define": 0,
"no-restricted-syntax": 0,
"new-cap": 0,
"no-bitwise": 0
}

@@ -91,5 +94,3 @@ },

"useTabs": true,
"printWidth": 120,
"parser": "flow",
"proseWrap": "never"
"printWidth": 120
},

@@ -107,3 +108,4 @@ "jest": {

}
}
},
"dependencies": {}
}
# Blork! Mini runtime type checking in Javascript
[![Travis CI](https://travis-ci.com/dhoulb/blork.svg?branch=master)](https://travis-ci.com/dhoulb/blork)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat)](https://github.com/semantic-release/semantic-release)
[![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat)](https://github.com/semantic-release/semantic-release)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![GitHub Actions](https://img.shields.io/github/workflow/status/dhoulb/blork/CI/master)](https://github.com/dhoulb/blork/actions)
[![npm](https://img.shields.io/npm/dm/blork.svg)](https://www.npmjs.com/package/blork)

@@ -42,3 +42,3 @@

```sh
yarn install blork
npm install blork
```

@@ -612,2 +612,2 @@

See [Releases](https://github.com/dhoulb/blork/releases)
See [Releases](https://github.com/dhoulb/blork/releases)

@@ -20,3 +20,3 @@ const ValueError = require("../lib/errors/ValueError");

// Define a checker called 'a11218'.
expect(add("a11218", v => typeof v === "string")).toBeUndefined();
expect(add("a11218", (v) => typeof v === "string")).toBeUndefined();

@@ -63,3 +63,3 @@ // Check a passing value.

// Define a checker called 'e618e0'.
expect(add("e618e0", v => typeof v === "string", "exactly correct")).toBeUndefined();
expect(add("e618e0", (v) => typeof v === "string", "exactly correct")).toBeUndefined();

@@ -66,0 +66,0 @@ // Check a passing value.

@@ -6,3 +6,3 @@ const { check } = require("../../lib/exports");

test("Works with empty arguments objects", () => {
(function() {
(function () {
expect(check(arguments, "arraylike")).toBe(undefined);

@@ -12,6 +12,6 @@ })();

test("Works with non-empty arguments objects", () => {
(function() {
(function () {
expect(check(arguments, "arraylike")).toBe(undefined);
})("abc", "abc");
(function() {
(function () {
expect(check(arguments, "arraylike")).toBe(undefined);

@@ -18,0 +18,0 @@ })("abc", 123, false);

@@ -87,4 +87,4 @@ const checkers = require("../../lib/checkers/checkers");

// Objects.
expect(mockCheck(function() {}, "function")).toBe(undefined);
expect(mockCheck(function() {}, "func")).toBe(undefined);
expect(mockCheck(function () {}, "function")).toBe(undefined);
expect(mockCheck(function () {}, "func")).toBe(undefined);
expect(mockCheck({}, "object")).toBe(undefined);

@@ -97,3 +97,3 @@ expect(mockCheck({ a: 1 }, "obj")).toBe(undefined);

expect(mockCheck([], "arr")).toBe(undefined);
expect(mockCheck({ "0": "abc", length: 1 }, "arraylike")).toBe(undefined);
expect(mockCheck({ "0": "abc", length: 1 }, "arraylike")).toBe(undefined); // prettier-ignore
expect(mockCheck({ length: 0 }, "arguments")).toBe(undefined);

@@ -131,4 +131,4 @@ expect(mockCheck({ length: 0 }, "args")).toBe(undefined);

const checkerNames = Object.keys(checkers);
checkerNames.forEach(name => expect(called).toContain(name));
called.forEach(name => expect(checkerNames).toContain(name));
checkerNames.forEach((name) => expect(called).toContain(name));
called.forEach((name) => expect(checkerNames).toContain(name));
expect(called.length).toBe(checkerNames.length);

@@ -255,6 +255,6 @@ });

const checkerNames = Object.keys(checkers);
checkerNames.forEach(name => expect(called).toContain(name));
called.forEach(name => expect(checkerNames).toContain(name));
checkerNames.forEach((name) => expect(called).toContain(name));
called.forEach((name) => expect(checkerNames).toContain(name));
expect(called.length).toBe(checkerNames.length);
});
});

@@ -21,3 +21,3 @@ const isCircular = require("../../lib/checkers/isCircular");

num: 123,
str: "abc"
str: "abc",
})

@@ -24,0 +24,0 @@ ).toBe(false);

@@ -10,9 +10,9 @@ const BlorkError = require("../../lib/errors/BlorkError");

test("Return correct error with message only", () => {
expect(new BlorkError("Message")).toHaveProperty("message", "test(): Message");
expect(new BlorkError("Message").message).toMatch("Message");
expect(new BlorkError("Message")).not.toHaveProperty("value");
});
test("Return correct error with message and value", () => {
expect(new BlorkError("Message", 123)).toHaveProperty("message", "test(): Message (received 123)");
expect(new BlorkError("Message", 123).message).toMatch("Message (received 123)");
expect(new BlorkError("Message", 123)).toHaveProperty("value", 123);
});
});

@@ -42,3 +42,3 @@ const { debug } = require("../../lib/exports");

b: "Yelp infallibly calmative buff centered.",
c: "Accommodatingly swain he for did fast."
c: "Accommodatingly swain he for did fast.",
})

@@ -57,3 +57,3 @@ ).toBe(`{

"Yelp infallibly calmative buff centered.",
"Accommodatingly swain he for did fast."
"Accommodatingly swain he for did fast.",
])

@@ -72,8 +72,8 @@ ).toBe(`[

test("Return correct debug string for functions", () => {
expect(debug(function() {})).toBe("function ()");
expect(debug(function () {})).toBe("function ()");
expect(debug(function dog() {})).toBe("dog()");
});
test("Return correct debug string for class instances", () => {
expect(debug(new class MyClass {}())).toBe("MyClass {}");
expect(debug(new class {}())).toBe("anonymous object {}");
expect(debug(new (class MyClass {})())).toBe("MyClass {}");
expect(debug(new (class {})())).toBe("anonymous object {}");
});

@@ -119,3 +119,3 @@ test("Return correct debug string for errors", () => {

test("Return correct debug for arguments objects", () => {
(function() {
(function () {
expect(debug(arguments)).toBe('{ "0": "abc", "1": 123, "2": true }');

@@ -122,0 +122,0 @@ })("abc", 123, true);

@@ -12,9 +12,9 @@ const destack = require("../../lib/helpers/destack");

expect(destack("Error\n at abc (file.js:1:2)")).toEqual([
{ function: "abc()", file: "file.js", line: 1, column: 2, original: " at abc (file.js:1:2)" }
{ function: "abc()", file: "file.js", line: 1, column: 2, original: " at abc (file.js:1:2)" },
]);
expect(destack("Error\n at abc (file.js:1)")).toEqual([
{ function: "abc()", file: "file.js", line: 1, column: null, original: " at abc (file.js:1)" }
{ function: "abc()", file: "file.js", line: 1, column: null, original: " at abc (file.js:1)" },
]);
expect(destack("Error\n at abc (file.js)")).toEqual([
{ function: "abc()", file: "file.js", line: null, column: null, original: " at abc (file.js)" }
{ function: "abc()", file: "file.js", line: null, column: null, original: " at abc (file.js)" },
]);

@@ -27,22 +27,22 @@ expect(destack("Error\n at <anonymous> (file.js:1:2)")).toEqual([

column: 2,
original: " at <anonymous> (file.js:1:2)"
}
original: " at <anonymous> (file.js:1:2)",
},
]);
expect(destack("Error\n at file.js:1:2")).toEqual([
{ function: "", file: "file.js", line: 1, column: 2, original: " at file.js:1:2" }
{ function: "", file: "file.js", line: 1, column: 2, original: " at file.js:1:2" },
]);
expect(destack("Error\n at file.js:1")).toEqual([
{ function: "", file: "file.js", line: 1, column: null, original: " at file.js:1" }
{ function: "", file: "file.js", line: 1, column: null, original: " at file.js:1" },
]);
expect(destack("Error\n at file.js")).toEqual([
{ function: "", file: "file.js", line: null, column: null, original: " at file.js" }
{ function: "", file: "file.js", line: null, column: null, original: " at file.js" },
]);
expect(destack("Error\n at <anonymous>:1:2")).toEqual([
{ function: "", file: "", line: 1, column: 2, original: " at <anonymous>:1:2" }
{ function: "", file: "", line: 1, column: 2, original: " at <anonymous>:1:2" },
]);
expect(destack("Error\n at <anonymous>:1")).toEqual([
{ function: "", file: "", line: 1, column: null, original: " at <anonymous>:1" }
{ function: "", file: "", line: 1, column: null, original: " at <anonymous>:1" },
]);
expect(destack("Error\n at <anonymous>")).toEqual([
{ function: "", file: "", line: null, column: null, original: " at <anonymous>" }
{ function: "", file: "", line: null, column: null, original: " at <anonymous>" },
]);

@@ -56,3 +56,3 @@ const stack2 = [

" at <anonymous>:1",
" at <anonymous>"
" at <anonymous>",
];

@@ -65,3 +65,3 @@ expect(destack(stack2.join("\n"))).toEqual([

{ function: "", file: "", line: 1, column: null, original: " at <anonymous>:1" },
{ function: "", file: "", line: null, column: null, original: " at <anonymous>" }
{ function: "", file: "", line: null, column: null, original: " at <anonymous>" },
]);

@@ -77,3 +77,3 @@ const stack3 = [

" at <anonymous>",
" at process._tickCallback (internal/process/next_tick.js:182:7)"
" at process._tickCallback (internal/process/next_tick.js:182:7)",
];

@@ -86,3 +86,3 @@ expect(destack(stack3.join("\n"))).toEqual([

column: 15,
original: " at Object.test (/blork/test/functions/destack.test.js:21:15)"
original: " at Object.test (/blork/test/functions/destack.test.js:21:15)",
},

@@ -94,3 +94,3 @@ {

column: 432,
original: " at Object.asyncFn (/jest-jasmine2/build/jasmine_async.js:129:432)"
original: " at Object.asyncFn (/jest-jasmine2/build/jasmine_async.js:129:432)",
},

@@ -102,3 +102,3 @@ {

column: 12,
original: " at resolve (/jest-jasmine2/build/queue_runner.js:51:12)"
original: " at resolve (/jest-jasmine2/build/queue_runner.js:51:12)",
},

@@ -110,3 +110,3 @@ {

column: null,
original: " at new Promise (<anonymous>)"
original: " at new Promise (<anonymous>)",
},

@@ -118,3 +118,3 @@ {

column: 274,
original: " at mapper (/jest-jasmine2/build/queue_runner.js:40:274)"
original: " at mapper (/jest-jasmine2/build/queue_runner.js:40:274)",
},

@@ -126,3 +126,3 @@ {

column: 39,
original: " at promise.then (/jest-jasmine2/build/queue_runner.js:83:39)"
original: " at promise.then (/jest-jasmine2/build/queue_runner.js:83:39)",
},

@@ -135,4 +135,4 @@ { function: "", file: "", line: null, column: null, original: " at <anonymous>" },

column: 7,
original: " at process._tickCallback (internal/process/next_tick.js:182:7)"
}
original: " at process._tickCallback (internal/process/next_tick.js:182:7)",
},
]);

@@ -148,4 +148,4 @@ });

column: 17,
original: "trace@file:///C:/example.html:9:17"
}
original: "trace@file:///C:/example.html:9:17",
},
]);

@@ -158,4 +158,4 @@ expect(destack("@file:///C:/example.html:16:13")).toEqual([

column: 13,
original: "@file:///C:/example.html:16:13"
}
original: "@file:///C:/example.html:16:13",
},
]);

@@ -168,4 +168,4 @@ expect(destack("a@file:///C:/example.html:19")).toEqual([

column: null,
original: "a@file:///C:/example.html:19"
}
original: "a@file:///C:/example.html:19",
},
]);

@@ -178,7 +178,7 @@ expect(destack("Object.a@file:///C:/example.html:19")).toEqual([

column: null,
original: "Object.a@file:///C:/example.html:19"
}
original: "Object.a@file:///C:/example.html:19",
},
]);
expect(destack("@debugger eval code:21:9")).toEqual([
{ function: "", file: "", line: 21, column: 9, original: "@debugger eval code:21:9" }
{ function: "", file: "", line: 21, column: 9, original: "@debugger eval code:21:9" },
]);

@@ -189,3 +189,3 @@ const stack1 = [

"a@file:///C:/example.html:19", // No column.
"@debugger eval code:21:9" // Console.
"@debugger eval code:21:9", // Console.
];

@@ -198,3 +198,3 @@ expect(destack(stack1.join("\n"))).toEqual([

column: 17,
original: "trace@file:///C:/example.html:9:17"
original: "trace@file:///C:/example.html:9:17",
},

@@ -206,3 +206,3 @@ {

column: 13,
original: "@file:///C:/example.html:16:13"
original: "@file:///C:/example.html:16:13",
},

@@ -214,5 +214,5 @@ {

column: null,
original: "a@file:///C:/example.html:19"
original: "a@file:///C:/example.html:19",
},
{ function: "", file: "", line: 21, column: 9, original: "@debugger eval code:21:9" }
{ function: "", file: "", line: 21, column: 9, original: "@debugger eval code:21:9" },
]);

@@ -226,3 +226,3 @@ // Safari.

"_evaluateOn",
"_evaluateAndWrap"
"_evaluateAndWrap",
];

@@ -237,8 +237,8 @@ expect(destack(stack2.join("\n"))).toEqual([

column: null,
original: "evaluateWithScopeExtension@[native code]"
original: "evaluateWithScopeExtension@[native code]",
},
{ function: "_evaluateOn()", file: "", line: null, column: null, original: "_evaluateOn" },
{ function: "_evaluateAndWrap()", file: "", line: null, column: null, original: "_evaluateAndWrap" }
{ function: "_evaluateAndWrap()", file: "", line: null, column: null, original: "_evaluateAndWrap" },
]);
});
});

@@ -11,4 +11,4 @@ const modifyChecker = require("../../lib/helpers/modifyChecker");

start: "++",
callback
}
callback,
},
];

@@ -25,4 +25,4 @@ const result = modifyChecker(modifiers, "++abc", checker);

end: "??",
callback
}
callback,
},
];

@@ -40,4 +40,4 @@ const result = modifyChecker(modifiers, "abc??", checker);

end: "}",
callback
}
callback,
},
];

@@ -55,4 +55,4 @@ const result = modifyChecker(modifiers, "{abc}", checker);

end: "'",
callback
}
callback,
},
];

@@ -69,4 +69,4 @@ const result = modifyChecker(modifiers, "'abc'", checker);

split: "|",
callback
}
callback,
},
];

@@ -84,4 +84,4 @@ const result = modifyChecker(modifiers, "abc | def", checker);

match,
callback
}
callback,
},
];

@@ -97,4 +97,4 @@ const result = modifyChecker(modifiers, "abc<123>", checker);

{
callback
}
callback,
},
];

@@ -101,0 +101,0 @@ const result = modifyChecker(modifiers, "abc<123>", checker);

@@ -12,3 +12,3 @@ const stackTrigger = require("../../lib/helpers/stackTrigger");

" at MyClass.name (MyClass.js:8:4)",
" at myFunc (helpers/myFunc.js:129:432)"
" at myFunc (helpers/myFunc.js:129:432)",
];

@@ -27,3 +27,3 @@

" at MyClass.name (MyClass.js:8:4)",
" at myFunc (helpers/myFunc.js:129:432)"
" at myFunc (helpers/myFunc.js:129:432)",
].join("\n")

@@ -41,3 +41,3 @@ );

" at MyClass.name (MyClass.js:8:4)",
" at myFunc (helpers/myFunc.js:129:432)"
" at myFunc (helpers/myFunc.js:129:432)",
];

@@ -56,3 +56,3 @@

" at MyClass.name (MyClass.js:8:4)",
" at myFunc (helpers/myFunc.js:129:432)"
" at myFunc (helpers/myFunc.js:129:432)",
].join("\n")

@@ -72,3 +72,3 @@ );

" at <anonymous>",
" at process._tickCallback (internal/process/next_tick.js:182:7)"
" at process._tickCallback (internal/process/next_tick.js:182:7)",
];

@@ -92,3 +92,3 @@

"MyClass.name@MyClass.js:8:4",
"myFunc@helpers/myFunc.js:129:432"
"myFunc@helpers/myFunc.js:129:432",
];

@@ -112,3 +112,3 @@

"MyClass.name@MyClass.js:8:4",
"myFunc@helpers/myFunc.js:129:432"
"myFunc@helpers/myFunc.js:129:432",
];

@@ -115,0 +115,0 @@

@@ -11,3 +11,11 @@ const { check, BlorkError } = require("../../lib/exports");

expect(check([1, "b", true], "array{3}")).toBe(undefined);
expect(check(new Map([[1, 1], [2, 2]]), "map{2}")).toBe(undefined);
expect(
check(
new Map([
[1, 1],
[2, 2],
]),
"map{2}"
)
).toBe(undefined);
expect(check(new Set([1, 2, "c", 4]), "set{4}")).toBe(undefined);

@@ -27,3 +35,12 @@ expect(check(123, "number{123}")).toBe(undefined);

expect(() => check(new Map([[1, 1]]), "map{2}")).toThrow(TypeError);
expect(() => check(new Map([[1, 1], [2, 2], [3, 3]]), "map{2}")).toThrow(TypeError);
expect(() =>
check(
new Map([
[1, 1],
[2, 2],
[3, 3],
]),
"map{2}"
)
).toThrow(TypeError);
expect(() => check(new Set([1, 2, 3]), "set{4}")).toThrow(TypeError);

@@ -47,3 +64,11 @@ expect(() => check(new Set([1, 2, 3, 4, 5]), "set{4}")).toThrow(TypeError);

expect(check([1, "b", true, 4], "array{3,}")).toBe(undefined);
expect(check(new Map([[1, 1], [2, 2]]), "map{1,}")).toBe(undefined);
expect(
check(
new Map([
[1, 1],
[2, 2],
]),
"map{1,}"
)
).toBe(undefined);
expect(check(new Set([1, 2, "c", 4]), "set{4,}")).toBe(undefined);

@@ -75,3 +100,11 @@ expect(check(124, "number{123,}")).toBe(undefined);

expect(check([1, "b", true, 4], "array{,4}")).toBe(undefined);
expect(check(new Map([[1, 1], [2, 2]]), "map{,2}")).toBe(undefined);
expect(
check(
new Map([
[1, 1],
[2, 2],
]),
"map{,2}"
)
).toBe(undefined);
expect(check(new Set([1, 2, "c", 4]), "set{,4}")).toBe(undefined);

@@ -103,3 +136,11 @@ expect(check(124, "number{,124}")).toBe(undefined);

expect(check([1, "b", true, 4], "array{3,6}")).toBe(undefined);
expect(check(new Map([[1, 1], [2, 2]]), "map{1,6}")).toBe(undefined);
expect(
check(
new Map([
[1, 1],
[2, 2],
]),
"map{1,6}"
)
).toBe(undefined);
expect(check(new Set([1, 2, "c", 4]), "set{4,6}")).toBe(undefined);

@@ -118,3 +159,13 @@ expect(check(124, "number{123,125}")).toBe(undefined);

expect(() => check(new Map([["a", 2]]), "map{2,3}")).toThrow(TypeError);
expect(() => check(new Map([["a", 2], ["b", 3], ["c", 4], ["d", 5]]), "map{2,3}")).toThrow(TypeError);
expect(() =>
check(
new Map([
["a", 2],
["b", 3],
["c", 4],
["d", 5],
]),
"map{2,3}"
)
).toThrow(TypeError);
expect(() => check(new Set([1]), "set{2,3}")).toThrow(TypeError);

@@ -121,0 +172,0 @@ expect(() => check(new Set([1, 2, 3, 4]), "set{2,3}")).toThrow(TypeError);

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