From 71682edbcb10d49101f5442e5673b441694da1ca Mon Sep 17 00:00:00 2001 From: shtse8 Date: Thu, 14 Mar 2024 06:47:07 +0800 Subject: [PATCH] format the codes --- src/index.ts | 6 +++--- src/tests/typed.test.ts | 36 ++++++++++++++++++------------------ src/typed.ts | 8 ++++---- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/index.ts b/src/index.ts index 99a86e68..da0f6aa6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -93,12 +93,12 @@ export { isFloat, isFunction, isInt, + isNonNullish, + isNullish, isNumber, isObject, isPrimitive, isPromise, isString, - isSymbol, - isNonNullish, - isNullish, + isSymbol } from './typed' diff --git a/src/tests/typed.test.ts b/src/tests/typed.test.ts index 8361ae51..fb4e444e 100644 --- a/src/tests/typed.test.ts +++ b/src/tests/typed.test.ts @@ -20,7 +20,7 @@ describe('typed module', () => { assert.isFalse(result) }) test('returns false for class instance', () => { - class Data { } + class Data {} const result = _.isArray(new Data()) assert.isFalse(result) }) @@ -56,7 +56,7 @@ describe('typed module', () => { assert.isFalse(result) }) test('returns false for class instance', () => { - class Data { } + class Data {} const result = _.isObject(new Data()) assert.isFalse(result) }) @@ -117,7 +117,7 @@ describe('typed module', () => { assert.isFalse(result) }) test('returns false for class instance', () => { - class Data { } + class Data {} const result = _.isFunction(new Data()) assert.isFalse(result) }) @@ -172,7 +172,7 @@ describe('typed module', () => { assert.isFalse(result) }) test('returns false for class instance', () => { - class Data { } + class Data {} const result = _.isString(new Data()) assert.isFalse(result) }) @@ -212,7 +212,7 @@ describe('typed module', () => { assert.isFalse(result) }) test('returns false for class instance', () => { - class Data { } + class Data {} const result = _.isNumber(new Data()) assert.isFalse(result) }) @@ -247,7 +247,7 @@ describe('typed module', () => { }) describe('isInt function', () => { - class Data { } + class Data {} test('returns false for non-number values', () => { assert.isFalse(_.isInt(undefined)) assert.isFalse(_.isInt(null)) @@ -270,7 +270,7 @@ describe('typed module', () => { }) describe('isFloat function', () => { - class Data { } + class Data {} test('returns false for non-number values', () => { assert.isFalse(_.isFloat(undefined)) assert.isFalse(_.isFloat(null)) @@ -293,7 +293,7 @@ describe('typed module', () => { }) describe('isEmpty function', () => { - class Data { } + class Data {} class Person { name: string = 'ray' } @@ -320,8 +320,8 @@ describe('typed module', () => { assert.isFalse(_.isEmpty('abc')) assert.isFalse(_.isEmpty(String('abc'))) assert.isFalse(_.isEmpty([1, 2, 3])) - assert.isFalse(_.isEmpty(function work() { })) - assert.isFalse(_.isEmpty(() => { })) + assert.isFalse(_.isEmpty(function work() {})) + assert.isFalse(_.isEmpty(() => {})) assert.isFalse(_.isEmpty(Symbol(''))) assert.isFalse(_.isEmpty(Symbol('hello'))) const map = new Map() @@ -342,8 +342,8 @@ describe('typed module', () => { assert.isFalse(_.isDate('abc')) assert.isFalse(_.isDate(String('abc'))) assert.isFalse(_.isDate([1, 2, 3])) - assert.isFalse(_.isDate(function work() { })) - assert.isFalse(_.isDate(() => { })) + assert.isFalse(_.isDate(function work() {})) + assert.isFalse(_.isDate(() => {})) assert.isFalse(_.isDate(Symbol(''))) assert.isFalse(_.isDate(Symbol('hello'))) }) @@ -353,7 +353,7 @@ describe('typed module', () => { test('return true for Promise values', () => { assert.isTrue(_.isPromise(new Promise(res => res(0)))) assert.isTrue(_.isPromise(new Promise(res => res('')))) - assert.isTrue(_.isPromise((async () => { })())) + assert.isTrue(_.isPromise((async () => {})())) }) test('return false for non-Date values', () => { assert.isFalse(_.isPromise(22)) @@ -361,8 +361,8 @@ describe('typed module', () => { assert.isFalse(_.isPromise('abc')) assert.isFalse(_.isPromise(String('abc'))) assert.isFalse(_.isPromise([1, 2, 3])) - assert.isFalse(_.isPromise(function work() { })) - assert.isFalse(_.isPromise(() => { })) + assert.isFalse(_.isPromise(function work() {})) + assert.isFalse(_.isPromise(() => {})) assert.isFalse(_.isPromise(Symbol(''))) assert.isFalse(_.isPromise(Symbol('hello'))) assert.isFalse(_.isPromise({ then: 2 })) @@ -381,7 +381,7 @@ describe('typed module', () => { assert.isFalse(result) }) test('returns false for empty class instance', () => { - class Data { } + class Data {} const input = new Data() const result = _.isSymbol(input) assert.isFalse(result) @@ -553,7 +553,7 @@ describe('typed module', () => { assert.isFalse(_.isNullish(false)) assert.isFalse(_.isNullish([])) assert.isFalse(_.isNullish({})) - assert.isFalse(_.isNullish(() => { })) + assert.isFalse(_.isNullish(() => {})) assert.isFalse(_.isNullish(Symbol(''))) assert.isFalse(_.isNullish(new Date())) }) @@ -570,7 +570,7 @@ describe('typed module', () => { assert.isTrue(_.isNonNullish(false)) assert.isTrue(_.isNonNullish([])) assert.isTrue(_.isNonNullish({})) - assert.isTrue(_.isNonNullish(() => { })) + assert.isTrue(_.isNonNullish(() => {})) assert.isTrue(_.isNonNullish(Symbol(''))) assert.isTrue(_.isNonNullish(new Date())) }) diff --git a/src/typed.ts b/src/typed.ts index dbb64a36..3a605ad7 100644 --- a/src/typed.ts +++ b/src/typed.ts @@ -105,7 +105,6 @@ export const isEqual = (x: TType, y: TType): boolean => { return true } - /** * Checks if the given value is null or undefined. */ @@ -113,10 +112,11 @@ export const isNullish = (value: any): value is null | undefined => { return value === null || value === undefined } - /** * Checks if the given value is not null or undefined. */ -export const isNonNullish = (value: TType): value is Exclude => { +export const isNonNullish = ( + value: TType +): value is Exclude => { return value !== null && value !== undefined -} \ No newline at end of file +}