chore: update to version 14.0.11 and align website URLs

This commit is contained in:
2026-01-11 11:34:13 +03:00
parent ef74383349
commit 19c8d69bd8
1499 changed files with 53633 additions and 89 deletions
+13
View File
@@ -0,0 +1,13 @@
import type { AnyString } from '../types.js';
export declare const CC_TO_UP: string[];
export declare const CC_TO_LO: string[];
/**
* @name stringCamelCase
* @summary Convert a dash/dot/underscore/space separated Ascii string/String to camelCase
*/
export declare const stringCamelCase: (value: AnyString) => string;
/**
* @name stringPascalCase
* @summary Convert a dash/dot/underscore/space separated Ascii string/String to PascalCase
*/
export declare const stringPascalCase: (value: AnyString) => string;
+59
View File
@@ -0,0 +1,59 @@
export const CC_TO_UP = new Array(256);
export const CC_TO_LO = new Array(256);
for (let i = 0, count = CC_TO_UP.length; i < count; i++) {
CC_TO_LO[i] = String.fromCharCode(i).toLowerCase();
CC_TO_UP[i] = String.fromCharCode(i).toUpperCase();
}
/** @internal */
function formatAllCaps(w) {
return w.slice(0, w.length - 1).toLowerCase() + CC_TO_UP[w.charCodeAt(w.length - 1)];
}
/**
* @internal
*
* Inspired by https://stackoverflow.com/a/2970667
*
* This is not as optimal as the original SO answer (we split into per-word),
* however it does pass the tests (which the SO version doesn't) and is still
* a major improvement over the original camelcase npm package -
*
* camelcase: 20.88 μs/op
* this: 1.00 μs/op
*
* Caveat of this: only Ascii, but acceptable for the intended usecase
*/
function converter(format) {
return (value) => {
const parts = value
// replace all separators (including consequtive) with spaces
.replace(/[-_., ]+/g, ' ')
// we don't want leading or trailing spaces
.trim()
// split into words
.split(' ');
let result = '';
for (let i = 0, count = parts.length; i < count; i++) {
const w = parts[i];
// apply the formatting
result += format(/^[\dA-Z]+$/.test(w)
// all full uppercase + letters are changed to lowercase
? w.toLowerCase()
// all consecutive capitals + letters are changed to lowercase
// e.g. UUID64 -> uuid64, while preserving splits, eg. NFTOrder -> nftOrder
: w.replace(/^[\dA-Z]{2,}[^a-z]/, formatAllCaps), i);
}
return result;
};
}
/**
* @name stringCamelCase
* @summary Convert a dash/dot/underscore/space separated Ascii string/String to camelCase
*/
export const stringCamelCase = /*#__PURE__*/ converter((w, i) =>
(i ? CC_TO_UP[w.charCodeAt(0)] : CC_TO_LO[w.charCodeAt(0)]) + w.slice(1));
/**
* @name stringPascalCase
* @summary Convert a dash/dot/underscore/space separated Ascii string/String to PascalCase
*/
export const stringPascalCase = /*#__PURE__*/ converter((w) =>
CC_TO_UP[w.charCodeAt(0)] + w.slice(1));
+8
View File
@@ -0,0 +1,8 @@
/**
* @summary Utility methods to convert to work with `string` values
*/
export { stringCamelCase, stringPascalCase } from './camelCase.js';
export { stringLowerFirst, stringUpperFirst } from './lowerFirst.js';
export { stringShorten } from './shorten.js';
export { stringToHex } from './toHex.js';
export { stringToU8a } from './toU8a.js';
+8
View File
@@ -0,0 +1,8 @@
/**
* @summary Utility methods to convert to work with `string` values
*/
export { stringCamelCase, stringPascalCase } from './camelCase.js';
export { stringLowerFirst, stringUpperFirst } from './lowerFirst.js';
export { stringShorten } from './shorten.js';
export { stringToHex } from './toHex.js';
export { stringToU8a } from './toU8a.js';
+31
View File
@@ -0,0 +1,31 @@
import type { AnyString } from '../types.js';
/**
* @name stringLowerFirst
* @summary Lowercase the first letter of a string
* @description
* Lowercase the first letter of a string
* @example
* <BR>
*
* ```javascript
* import { stringLowerFirst } from '@pezkuwi/util';
*
* stringLowerFirst('ABC'); // => 'aBC'
* ```
*/
export declare const stringLowerFirst: (value?: AnyString | null) => string;
/**
* @name stringUpperFirst
* @summary Uppercase the first letter of a string
* @description
* Lowercase the first letter of a string
* @example
* <BR>
*
* ```javascript
* import { stringUpperFirst } from '@pezkuwi/util';
*
* stringUpperFirst('abc'); // => 'Abc'
* ```
*/
export declare const stringUpperFirst: (value?: AnyString | null) => string;
+37
View File
@@ -0,0 +1,37 @@
import { CC_TO_LO, CC_TO_UP } from './camelCase.js';
/** @internal */
function converter(map) {
return (value) => value
? map[value.charCodeAt(0)] + value.slice(1)
: '';
}
/**
* @name stringLowerFirst
* @summary Lowercase the first letter of a string
* @description
* Lowercase the first letter of a string
* @example
* <BR>
*
* ```javascript
* import { stringLowerFirst } from '@pezkuwi/util';
*
* stringLowerFirst('ABC'); // => 'aBC'
* ```
*/
export const stringLowerFirst = /*#__PURE__*/ converter(CC_TO_LO);
/**
* @name stringUpperFirst
* @summary Uppercase the first letter of a string
* @description
* Lowercase the first letter of a string
* @example
* <BR>
*
* ```javascript
* import { stringUpperFirst } from '@pezkuwi/util';
*
* stringUpperFirst('abc'); // => 'Abc'
* ```
*/
export const stringUpperFirst = /*#__PURE__*/ converter(CC_TO_UP);
+16
View File
@@ -0,0 +1,16 @@
import type { AnyString } from '../types.js';
/**
* @name stringShorten
* @summary Returns a string with maximum length
* @description
* Checks the string against the `prefixLength`, if longer than double this, shortens it by placing `..` in the middle of it
* @example
* <BR>
*
* ```javascript
* import { stringShorten } from '@pezkuwi/util';
*
* stringShorten('1234567890', 2); // => 12..90
* ```
*/
export declare function stringShorten(value: AnyString, prefixLength?: number): string;
+19
View File
@@ -0,0 +1,19 @@
/**
* @name stringShorten
* @summary Returns a string with maximum length
* @description
* Checks the string against the `prefixLength`, if longer than double this, shortens it by placing `..` in the middle of it
* @example
* <BR>
*
* ```javascript
* import { stringShorten } from '@pezkuwi/util';
*
* stringShorten('1234567890', 2); // => 12..90
* ```
*/
export function stringShorten(value, prefixLength = 6) {
return value.length <= 2 + 2 * prefixLength
? value.toString()
: `${value.substring(0, prefixLength)}${value.slice(-prefixLength)}`;
}
+16
View File
@@ -0,0 +1,16 @@
import type { AnyString, HexString } from '../types.js';
/**
* @name stringToHex
* @summary Creates a hex string from a utf-8 string
* @description
* String input values return the actual encoded hex value.
* @example
* <BR>
*
* ```javascript
* import { stringToHex } from '@pezkuwi/util';
*
* stringToU8a('hello'); // 0x68656c6c6f
* ```
*/
export declare function stringToHex(value?: AnyString): HexString;
+19
View File
@@ -0,0 +1,19 @@
import { u8aToHex } from '../u8a/toHex.js';
import { stringToU8a } from './toU8a.js';
/**
* @name stringToHex
* @summary Creates a hex string from a utf-8 string
* @description
* String input values return the actual encoded hex value.
* @example
* <BR>
*
* ```javascript
* import { stringToHex } from '@pezkuwi/util';
*
* stringToU8a('hello'); // 0x68656c6c6f
* ```
*/
export function stringToHex(value) {
return u8aToHex(stringToU8a(value));
}
+16
View File
@@ -0,0 +1,16 @@
import type { AnyString } from '../types.js';
/**
* @name stringToU8a
* @summary Creates a Uint8Array object from a utf-8 string.
* @description
* String input values return the actual encoded `UInt8Array`. `null` or `undefined` values returns an empty encoded array.
* @example
* <BR>
*
* ```javascript
* import { stringToU8a } from '@pezkuwi/util';
*
* stringToU8a('hello'); // [0x68, 0x65, 0x6c, 0x6c, 0x6f]
* ```
*/
export declare function stringToU8a(value?: AnyString | null): Uint8Array;
+21
View File
@@ -0,0 +1,21 @@
import { TextEncoder } from '@pezkuwi/x-textencoder';
const encoder = new TextEncoder();
/**
* @name stringToU8a
* @summary Creates a Uint8Array object from a utf-8 string.
* @description
* String input values return the actual encoded `UInt8Array`. `null` or `undefined` values returns an empty encoded array.
* @example
* <BR>
*
* ```javascript
* import { stringToU8a } from '@pezkuwi/util';
*
* stringToU8a('hello'); // [0x68, 0x65, 0x6c, 0x6c, 0x6f]
* ```
*/
export function stringToU8a(value) {
return value
? encoder.encode(value.toString())
: new Uint8Array();
}