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.1.1 to 9.2.0

24

lib/checkers/checkers.js

@@ -12,9 +12,10 @@ /* eslint-disable prettier/prettier */

const R_LOWER = /^[a-z]+$/;
const R_CAMEL = /^[a-z][a-zA-Z0-9]*$/;
const R_PASCAL = /^[A-Z][a-zA-Z0-9]*$/;
const R_SNAKE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
const R_SCREAMING = /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/;
const R_KEBAB = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
const R_TRAIN = /^[A-Z][a-zA-Z0-9]*(-[A-Z0-9][a-zA-Z0-9]+)*$/;
const R_CAMEL = /^[a-z][a-zA-Z0-9]*$/; // e.g. myVarName
const R_PASCAL = /^[A-Z][a-zA-Z0-9]*$/; // e.g. MyVarName
const R_SNAKE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/; // e.g. my_var_name
const R_SCREAMING = /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/; // e.g. MY_VAR_NAME
const R_KEBAB = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/; // e.g. my-var-name
const R_TRAIN = /^[A-Z][a-zA-Z0-9]*(-[A-Z0-9][a-zA-Z0-9]+)*$/; // e.g. My-Var-Name
const R_IDENTIFIER = /^[$a-zA-Z_][a-zA-Z0-9_$]*$/;
const R_ABSOLUTE = /^(?:\/|[a-zA-Z]:\\|[/\\]{2}[^/\\]+[/\\/]+[^/\\]+)()/; // e.g. "/" (Unix) "C:\" (Windows) or "//server/file" or "\\server\file" (UNC)

@@ -58,2 +59,5 @@ // Checkers.

function isIdentifier(v) { return typeof v === "string" && R_IDENTIFIER.test(v); }
function isPath(v) { return typeof v === "string" && v.length > 0 && v.length <= 260 && v.indexOf(String.fromCharCode(0)) === -1; } // Total length is no more than 260 (Windows), doesn't contain NUL (Windows and Unix).
function isAbsolute(v) { return isPath(v) && R_ABSOLUTE.test(v); }
function isRelative(v) { return isPath(v) && !R_ABSOLUTE.test(v); }
function isPrimitive(v) { return v === undefined || v === null || typeof v === "boolean" || typeof v === "string" || Number.isFinite(v); }

@@ -122,2 +126,5 @@ function isFunction(v) { return typeof v === "function"; }

isIdentifier.desc = "valid JavaScript identifier";
isPath.desc = "valid path";
isAbsolute.desc = "absolute path";
isRelative.desc = "relative path";
isFunction.desc = "function";

@@ -212,2 +219,7 @@ isObject.desc = "object";

"identifier": isIdentifier,
"path": isPath,
"abs": isAbsolute,
"absolute": isAbsolute,
"rel": isRelative,
"relative": isRelative,

@@ -214,0 +226,0 @@ // Objects.

{
"name": "blork",
"description": "Blork! Mini runtime type checking in Javascript",
"version": "9.1.1",
"version": "9.2.0",
"license": "0BSD",

@@ -6,0 +6,0 @@ "author": "Dave Houlbrooke <dave@shax.com>",

@@ -274,2 +274,5 @@ # Blork! Mini runtime type checking in Javascript

| `identifier` | JavaScript identifier names (string starting with **_**, **$**, or letter)
| `path` | Valid filesystem path (e.g. "abc/def")
| `absolute`, `abs` | Valid absolute path (e.g. "/abc/def" or "C:\abd\def")
| `relative`, `rel` | Valid relative path (e.g. "../abc/def" or "..\abd\def")
| `function`, `func` | Functions (using **instanceof Function**)

@@ -276,0 +279,0 @@ | `object`, `obj` | Plain objects (using **typeof && !null** and constructor check)

@@ -80,2 +80,7 @@ const checkers = require("../../lib/checkers/checkers");

expect(mockCheck("$name", "identifier")).toBe(undefined);
expect(mockCheck("abc/def", "path")).toBe(undefined);
expect(mockCheck("..\\abc\\def", "rel")).toBe(undefined);
expect(mockCheck("../abc/def", "relative")).toBe(undefined);
expect(mockCheck("/abc/def", "abs")).toBe(undefined);
expect(mockCheck("C:\\abc\\def", "absolute")).toBe(undefined);

@@ -199,2 +204,7 @@ // Objects.

expect(() => mockCheck("*name", "identifier")).toThrow(TypeError);
expect(() => mockCheck(String.fromCharCode(0), "path")).toThrow(TypeError);
expect(() => mockCheck("/abc/def", "rel")).toThrow(TypeError);
expect(() => mockCheck("C:\\abc\\def", "relative")).toThrow(TypeError);
expect(() => mockCheck("../abc/def", "abs")).toThrow(TypeError);
expect(() => mockCheck("..\\abc\\def", "absolute")).toThrow(TypeError);

@@ -201,0 +211,0 @@ // Objects.

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