@rauschma/helpers
Advanced tools
Comparing version 0.1.0 to 0.2.0
export declare enum MatchMode { | ||
/** No gaps between matches */ | ||
AtLastIndex = "AtLastIndex", | ||
/** There can be gaps between matches */ | ||
AtLastIndexOrLater = "AtLastIndexOrLater" | ||
@@ -4,0 +6,0 @@ } |
const { raw } = String; | ||
export var MatchMode; | ||
(function (MatchMode) { | ||
/** No gaps between matches */ | ||
MatchMode["AtLastIndex"] = "AtLastIndex"; | ||
/** There can be gaps between matches */ | ||
MatchMode["AtLastIndexOrLater"] = "AtLastIndexOrLater"; | ||
@@ -11,3 +13,3 @@ })(MatchMode || (MatchMode = {})); | ||
if (!regExp.sticky) { | ||
throw new TypeError(`If flag /y is not set, matching ${matchMode} won’t work: ${regExp}`); | ||
throw new TypeError(`Flag /y must be set for matching ${matchMode}: ${regExp}`); | ||
} | ||
@@ -17,6 +19,6 @@ break; | ||
if (!regExp.global) { | ||
throw new TypeError(`If flag /g is not set, matching ${matchMode} won’t work: ${regExp}`); | ||
throw new TypeError(`Flag /g must be set for matching ${matchMode}: ${regExp}`); | ||
} | ||
if (regExp.sticky) { | ||
throw new TypeError(`If flag /y is set, matching ${matchMode} won’t work: ${regExp}`); | ||
throw new TypeError(`Flag /y must be set for matching ${matchMode}: ${regExp}`); | ||
} | ||
@@ -23,0 +25,0 @@ break; |
@@ -21,3 +21,3 @@ /** | ||
export declare function assertTrue(value: boolean, message?: string): asserts value; | ||
export declare function assertNonNullable<T>(value: T): asserts value is NonNullable<T>; | ||
export declare function assertNonNullable<T>(value: T, message?: string): asserts value is NonNullable<T>; | ||
type TypeofLookupTable = { | ||
@@ -24,0 +24,0 @@ 'undefined': undefined; |
@@ -29,5 +29,6 @@ //#################### Class #################### | ||
} | ||
export function assertNonNullable(value) { | ||
export function assertNonNullable(value, message) { | ||
if (value === undefined || value === null) { | ||
throw new TypeError('Value must not be undefined or null'); | ||
message ??= 'Value must not be undefined or null'; | ||
throw new TypeError('Failed: ' + message); | ||
} | ||
@@ -34,0 +35,0 @@ } |
{ | ||
"name": "@rauschma/helpers", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"type": "module", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rauschma/helpers.git" | ||
}, | ||
"author": "Axel Rauschmayer", | ||
"repository": "github:rauschma/helpers", | ||
"license": "MIT", | ||
"exports": { | ||
@@ -36,2 +39,3 @@ "./*": "./dist/src/*" | ||
"scripts": { | ||
"\n========== Building ==========": "", | ||
"build": "npm run clean && tsc", | ||
@@ -44,5 +48,5 @@ "watch": "tsc --watch", | ||
"\n========== Publishing ==========": "", | ||
"dry-run": "npm publish --dry-run", | ||
"prepublishOnly": "npm run build", | ||
"pack": "npm pack && tar --list --file rauschma-helpers-*.tgz" | ||
"publishd": "npm publish --dry-run", | ||
"packd": "npm pack --dry-run" | ||
}, | ||
@@ -49,0 +53,0 @@ "devDependencies": { |
const {raw} = String; | ||
export enum MatchMode { | ||
/** No gaps between matches */ | ||
AtLastIndex = 'AtLastIndex', | ||
/** There can be gaps between matches */ | ||
AtLastIndexOrLater = 'AtLastIndexOrLater', | ||
@@ -12,3 +14,3 @@ } | ||
if (!regExp.sticky) { | ||
throw new TypeError(`If flag /y is not set, matching ${matchMode} won’t work: ${regExp}`); | ||
throw new TypeError(`Flag /y must be set for matching ${matchMode}: ${regExp}`); | ||
} | ||
@@ -18,6 +20,6 @@ break; | ||
if (!regExp.global) { | ||
throw new TypeError(`If flag /g is not set, matching ${matchMode} won’t work: ${regExp}`); | ||
throw new TypeError(`Flag /g must be set for matching ${matchMode}: ${regExp}`); | ||
} | ||
if (regExp.sticky) { | ||
throw new TypeError(`If flag /y is set, matching ${matchMode} won’t work: ${regExp}`); | ||
throw new TypeError(`Flag /y must be set for matching ${matchMode}: ${regExp}`); | ||
} | ||
@@ -24,0 +26,0 @@ break; |
@@ -48,5 +48,6 @@ //#################### Class #################### | ||
export function assertNonNullable<T>(value: T): asserts value is NonNullable<T> { | ||
export function assertNonNullable<T>(value: T, message?: string): asserts value is NonNullable<T> { | ||
if (value === undefined || value === null) { | ||
throw new TypeError('Value must not be undefined or null'); | ||
message ??= 'Value must not be undefined or null'; | ||
throw new TypeError('Failed: ' + message); | ||
} | ||
@@ -53,0 +54,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
96983
1744
0