@universe/util
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -47,10 +47,10 @@ export declare const isNull: (v: unknown) => v is null; | ||
export declare const uuid: () => string; | ||
export declare function base85UuidEncode(uuid: string): string; | ||
export declare function base85UuidDecode(data: string): string | null; | ||
export declare const base64UrlEncode: (str: string) => string; | ||
export declare const base64UrlDecode: (str: string) => string; | ||
export declare function base85UuidEncode(uuid: string): string; | ||
export declare function base85UuidDecode(data: string): string | null; | ||
export declare const GET: <O>(url: string, headers?: {}) => Promise<O>; | ||
export declare const POST: <O>(url: string, data?: Json, headers?: {}) => Promise<O>; | ||
export declare const debounce: <F extends (...args: any) => any>(func: F, timeout: number) => (this: ThisParameterType<F>, ...args: Parameters<F>) => Promise<ReturnType<F>>; | ||
export declare function validateEmail(email?: string | null): boolean; | ||
export declare function validateEmail(email: any): email is string; | ||
export declare const abbrNum: (num: number, fixed?: number | undefined) => string | null; | ||
@@ -57,0 +57,0 @@ export declare function sha256Digest(message: string): Promise<string>; |
@@ -45,3 +45,3 @@ "use strict"; | ||
}); | ||
it('runs md5', function () { | ||
it.only('runs md5', function () { | ||
assert.strictEqual(index_1.md5('hello'), '5d41402abc4b2a76b9719d911017c592'); | ||
@@ -57,3 +57,3 @@ assert.strictEqual(index_1.md5('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 'c1906fa4ec71ebdc02c49c5d19908a39'); | ||
}); | ||
it.only('runs base85Encode / base85Encode', function () { | ||
it('runs base85UuidEncode / base85UuidEncode', function () { | ||
for (let i = 0; i < 20000; i++) { | ||
@@ -74,2 +74,7 @@ const id = index_1.uuid(); | ||
assert.ok(!index_1.validateEmail('superduperlongemailaddressthatistechnicallynotallowedsuperduperlongemailaddressthatistechnicallynotallowed@universe.app')); | ||
assert.ok(!index_1.validateEmail('INVALID')); | ||
assert.ok(!index_1.validateEmail(false)); | ||
assert.ok(!index_1.validateEmail(100)); | ||
assert.ok(!index_1.validateEmail(new Date()));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VwZXJkdXBlcmxvbmdlbWFpbGFkZHJlc3N0aGF0aXN0ZWNobmljYWxseW5vdGFsbG93ZWRAdW5pdmVyc2UuYXBwJykpO1xuICAgICAgYXNzZXJ0Lm9rKCF2YWxpZGF0ZUVtYWlsKCdJTlZBTElEJykpO1xuICAgICAgYXNzZXJ0Lm9rKCF2YWxpZGF0ZUVtYWlsKGZhbHNlKSk7XG4gICAgICBhc3NlcnQub2soIXZhbGlkYXRlRW1haWwoMTAwKSk7XG4gICAgICBhc3NlcnQub2soIXZhbGlkYXRlRW1haWwobmV3IERhdGUoKSkpO1xuICAgICAgYXNzZXJ0Lm9rKCF2YWxpZGF0ZUVtYWlsKHt9KSk7XG4gICAgfSk7XG5cbiAgICBpdCgnZGVlcCBjbG9uZXMnLCBhc3luYygpID0+IHtcbiAgICAgIGNvbnN0IG9iaiA9IHtcbiAgICAgICAgYTogMSxcbiAgICAgICAgYjogeyBjOiAzIH0sXG4gICAgICAgIGQ6IFsgMSwgMiwgeyBlOiA1IH1dLFxuICAgICAgfTtcbiAgICAgIGNvbnN0IGNsb25lID0gYXdhaXQgZGVlcENsb25lKG9iaik7XG4gICAgICBhc3NlcnQubm90U3RyaWN0RXF1YWwob2JqLCBjbG9uZSk7XG4gICAgICBhc3NlcnQuZGVlcFN0cmljdEVxdWFsKG9iaiwgY2xvbmUpO1xuICAgIH0pO1xuICB9KTtcbn0pO1xuIl19 |
{ | ||
"name": "@universe/util", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "description": "Universe development utilities.", |
@@ -155,5 +155,7 @@ /* global MessageChannel */ | ||
const EMAIL_TEST = /^[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/; | ||
export function validateEmail(email?: string | null): boolean { | ||
const [ acct, addr ] = email?.split('@') || []; | ||
if (!email || acct?.length > 64 || addr?.length > 255 || addr.split('.').some((part: string) => part.length > 63)) return false; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
export function validateEmail(email: any): email is string { | ||
if (typeof email !== 'string') { return false; } | ||
const [ acct = '', addr = '' ] = email.split('@') || []; | ||
if (!email || acct.length > 64 || addr.length > 255 || addr.split('.').some((part: string) => part.length > 63)) return false; | ||
return EMAIL_TEST.test(email); | ||
@@ -175,2 +177,4 @@ } | ||
export async function sha256Digest(message: string): Promise<string> { | ||
/* eslint-disable-next-line @typescript-eslint/no-var-requires */ | ||
if (!IS_BROWSER) { return require('crypto').createHash('sha256').update(message, 'utf8').digest('hex'); } | ||
const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array | ||
@@ -311,2 +315,4 @@ const hashBuffer = await window.crypto.subtle.digest('SHA-256', msgUint8); // hash the message | ||
export function md5(s: string): string { | ||
/* eslint-disable-next-line @typescript-eslint/no-var-requires */ | ||
if (!IS_BROWSER) { return require('crypto').createHash('md5').update(s).digest('hex'); } | ||
const n = s.length; | ||
@@ -313,0 +319,0 @@ const state = [ 1732584193, -271733879, -1732584194, 271733878 ]; |
@@ -46,3 +46,4 @@ /* global describe, it */ | ||
}); | ||
it('runs md5', function() { | ||
it.only('runs md5', function() { | ||
assert.strictEqual(md5('hello'), '5d41402abc4b2a76b9719d911017c592'); | ||
@@ -61,3 +62,3 @@ assert.strictEqual(md5('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 'c1906fa4ec71ebdc02c49c5d19908a39'); | ||
it.only('runs base85UuidEncode / base85UuidEncode', function() { | ||
it('runs base85UuidEncode / base85UuidEncode', function() { | ||
for (let i = 0; i < 20000; i++) { | ||
@@ -79,2 +80,7 @@ const id = uuid(); | ||
assert.ok(!validateEmail('superduperlongemailaddressthatistechnicallynotallowedsuperduperlongemailaddressthatistechnicallynotallowed@universe.app')); | ||
assert.ok(!validateEmail('INVALID')); | ||
assert.ok(!validateEmail(false)); | ||
assert.ok(!validateEmail(100)); | ||
assert.ok(!validateEmail(new Date())); | ||
assert.ok(!validateEmail({})); | ||
}); | ||
@@ -81,0 +87,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
424776
1078