Skip to content

Commit

Permalink
format the codes
Browse files Browse the repository at this point in the history
  • Loading branch information
shtse8 committed Mar 13, 2024
1 parent 4817a80 commit 71682ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ export {
isFloat,
isFunction,
isInt,
isNonNullish,
isNullish,
isNumber,
isObject,
isPrimitive,
isPromise,
isString,
isSymbol,
isNonNullish,
isNullish,
isSymbol
} from './typed'
36 changes: 18 additions & 18 deletions src/tests/typed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -293,7 +293,7 @@ describe('typed module', () => {
})

describe('isEmpty function', () => {
class Data { }
class Data {}
class Person {
name: string = 'ray'
}
Expand All @@ -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()
Expand All @@ -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')))
})
Expand All @@ -353,16 +353,16 @@ 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))
assert.isFalse(_.isPromise({ name: 'x' }))
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 }))
Expand All @@ -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)
Expand Down Expand Up @@ -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()))
})
Expand All @@ -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()))
})
Expand Down
8 changes: 4 additions & 4 deletions src/typed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ export const isEqual = <TType>(x: TType, y: TType): boolean => {
return true
}


/**
* Checks if the given value is null or undefined.
*/
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 = <TType>(value: TType): value is Exclude<TType, null | undefined> => {
export const isNonNullish = <TType>(
value: TType
): value is Exclude<TType, null | undefined> => {
return value !== null && value !== undefined
}
}

0 comments on commit 71682ed

Please sign in to comment.