@arktype/util
Advanced tools
Comparing version 0.0.50 to 0.0.51
@@ -38,7 +38,7 @@ import type { isDisjoint } from "./intersections.js"; | ||
* is created as `[value]` if value was not undefined, otherwise `[]`. | ||
* @param value The value to add to the array. If `value` is `undefined`, does nothing. | ||
* @param value The value to add to the array. | ||
* @param opts | ||
* prepend: If true, adds the element to the beginning of the array instead of the end | ||
*/ | ||
export declare const append: <to extends element[] | undefined, element, value extends listable<element> | undefined>(to: to, value: value, opts?: AppendOptions) => Exclude<to, undefined> | Extract<value & to, undefined>; | ||
export declare const append: <to extends unknown[] | undefined, value extends listable<(to & {})[number]>>(to: to, value: value, opts?: AppendOptions) => to & {}; | ||
/** | ||
@@ -45,0 +45,0 @@ * Concatenates an element or list with a readonly list |
@@ -37,3 +37,3 @@ export const join = (segments, delimiter) => segments.join(delimiter); | ||
* is created as `[value]` if value was not undefined, otherwise `[]`. | ||
* @param value The value to add to the array. If `value` is `undefined`, does nothing. | ||
* @param value The value to add to the array. | ||
* @param opts | ||
@@ -43,4 +43,2 @@ * prepend: If true, adds the element to the beginning of the array instead of the end | ||
export const append = (to, value, opts) => { | ||
if (value === undefined) | ||
return to ?? []; | ||
if (to === undefined) { | ||
@@ -47,0 +45,0 @@ return (value === undefined ? [] |
@@ -10,2 +10,13 @@ export declare const capitalize: <s extends string>(s: s) => Capitalize<s>; | ||
export declare const deanchoredSource: (regex: RegExp | string) => string; | ||
export declare const escapeToken = "\\"; | ||
export type EscapeToken = typeof escapeToken; | ||
export declare const whiteSpaceTokens: { | ||
readonly " ": true; | ||
readonly "\n": true; | ||
readonly "\t": true; | ||
}; | ||
export type WhiteSpaceToken = keyof typeof whiteSpaceTokens; | ||
export type trim<s extends string> = trimEnd<trimStart<s>>; | ||
export type trimStart<s extends string> = s extends `${WhiteSpaceToken}${infer tail}` ? trimEnd<tail> : s; | ||
export type trimEnd<s extends string> = s extends `${infer init}${WhiteSpaceToken}` ? trimEnd<init> : s; | ||
export type isStringLiteral<t> = [ | ||
@@ -12,0 +23,0 @@ t |
@@ -14,1 +14,7 @@ export const capitalize = (s) => (s[0].toUpperCase() + s.slice(1)); | ||
}; | ||
export const escapeToken = "\\"; | ||
export const whiteSpaceTokens = { | ||
" ": true, | ||
"\n": true, | ||
"\t": true | ||
}; |
{ | ||
"name": "@arktype/util", | ||
"version": "0.0.50", | ||
"version": "0.0.51", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "David Blass", |
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
79846
1649