@lindorm-io/core
TypeScript icon, indicating that this package has built-in type declarations

0.8.11 • Public • Published

@lindorm-io/core

Core utilities and files for lindorm.io packages

Installation

npm install --save @lindorm-io/core

Utilities

base64

Fully unnecessary but quick utility to make base64 parsing a bit easier so that you don't have to remember.

baseHash("string"); // -> "c3RyaW5n"
baseParse("c3RyaW5n"); // -> "string"

case switch

Extending some of the lodash case switching functions to also include arrays and records.

camelCase("snake_case"); // -> "snakeCase"
camelArray(["snake_case", "PascalCase"]); // -> ["snakeCase, pascalCase"]
camelKeys<Input, Output>({ snake_key: 123, PascalKey: true }); // -> { snakeKey: 123, pascalKey: true }

pascalCase("camelCase"); // -> "CamelCase"
pascalArray(["snake_case", "camelCase"]); // -> ["SnakeCase, CamelCase"]
pascalKeys<Input, Output>({ snake_key: 123, camelKey: true }); // -> { SnakeKey: 123, CamelKey: true }

pascalCase("PascalCase"); // -> "pascal_case"
pascalArray(["PascalCase", "camelCase"]); // -> ["pascal_case, camel_case"]
pascalKeys<Input, Output>({ PascalKey: 123, camelKey: true }); // -> { pascal_key: 123, camel_key: true }

random value

getRandomValue(12); // -> "rOjLkjjLFS2A"
getRandomNumber(6); // -> 703976

sort object keys

sortObjectKeys({ x: 3, a: 1, m: 2 }); // -> { a: 1, m: 2, x: 3 }

strict typing

Extending some of the lodash typing to be stricter.

isArrayStrict(["array"]); // -> true
isArrayStrict("string"); // -> false

isObjectStrict({ object: true }); // -> true
isObjectStrict(["array"]); // -> false
isObjectStrict(new Date()); // -> false
isObjectStrict(new Error()); // -> false

string comparison

Timing safe string comparison. A stricter and safer comparison utility.

stringComparison("string", "string"); // -> true

string to time

Generating time data from strings. Useful for date-fns which can take duration objects

stringToDurationObject("2 years 5 months"); // -> { years: 2, months: 5 }
stringToMilliseconds("12 seconds"); // -> 12000
stringToSeconds("5 minutes"); // -> 300000

Readme

Keywords

none

Package Sidebar

Install

npm i @lindorm-io/core

Weekly Downloads

6

Version

0.8.11

License

AGPL-3.0-or-later

Unpacked Size

29.9 kB

Total Files

64

Last publish

Collaborators

  • princejonn