Skip to content

Commit

Permalink
Merge pull request #35 from jsertx/feat/is-undefined
Browse files Browse the repository at this point in the history
feat: isUndefined
  • Loading branch information
vigan-abd authored Nov 20, 2024
2 parents 7b7b3b8 + 9ad524d commit a39b688
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#1.18.0
- feat: isUndefined

#1.17.0
- feat: assignWith
- feat: clone
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Currently supported utils:
- `isObjectLike` - Checks if passed `value` is object-like. A value is object-like if it's not `null`
- `isPlainObject` - checks if input is object, not null object and not array object
- `isString` - checks if input is a string
- `isUndefined` - checks if an input is undefined
- `mapKeys` - creates new object with the same values but with keys mapped by the provided function
- `mapValues` - Maps the values of an object or array using the provided iteratee function or property path
- `max` - computes the maximum value of array. If array is empty or falsey, undefined is returned
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function isObject (verifiable: any): Boolean
export function isObjectLike(value: any): boolean
export function isPlainObject (val: any): boolean
export function isString (val: any): boolean
export function isUndefined (val: any): boolean
export function mapKeys(obj: Object, mapper: (val: any, key: string) => string): Object
export function mapValues(obj: Object, mapper: (val: any, key: string) => any): Object
export function max (array: Array<any>): any
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const isObject = require('./src/isObject')
const isObjectLike = require('./src/isObjectLike')
const isPlainObject = require('./src/isPlainObject')
const isString = require('./src/isString')
const isUndefined = require('./src/isUndefined')
const mapKeys = require('./src/mapKeys')
const mapValues = require('./src/mapValues')
const max = require('./src/max')
Expand Down Expand Up @@ -75,6 +76,7 @@ module.exports = {
isObjectLike,
isPlainObject,
isString,
isUndefined,
mapKeys,
mapValues,
max,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitfinexcom/lib-js-util-base",
"version": "1.17.0",
"version": "1.18.0",
"description": "general utils",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/isUndefined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

const isUndefined = (val) => {
return val === undefined
}

module.exports = isUndefined
39 changes: 39 additions & 0 deletions test/isUndefined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict'

/* eslint-env mocha */
const assert = require('assert')
const isUndefined = require('../src/isUndefined')

describe('isUndefined', () => {
it('should return true for undefined', () => {
assert.ok(isUndefined(undefined))
})

it('should return true for no param', () => {
assert.ok(isUndefined())
})

it('should return false for empty object', () => {
assert.equal(isUndefined({}), false)
})

it('should return false for empty array', () => {
assert.equal(isUndefined([]), false)
})

it('should return false for null', () => {
assert.equal(isUndefined(null), false)
})

it('should return false for false', () => {
assert.equal(isUndefined(false), false)
})

it('should return false for empty string', () => {
assert.equal(isUndefined(''), false)
})

it('should return false for zero', () => {
assert.equal(isUndefined(0), false)
})
})

0 comments on commit a39b688

Please sign in to comment.