is-0 - v1.3.0
    Preparing search index...

    is-0 - v1.3.0

    is

    npm version CI codecov semantic-release: conventionalcommits

    NPM

    값이 empty인지 확인하는 단순하고 강력한 함수를 제공합니다.

    npm install is-0
    
    From GitHub Packages

    먼저 .npmrc 파일을 생성하거나 수정하세요:

    @SangHakLee:registry=https://npm.pkg.github.com
    

    그리고 GitHub Personal Access Token으로 인증:

    npm login --scope=@SangHakLee --registry=https://npm.pkg.github.com
    

    패키지 설치:

    npm install @SangHakLee/is-0
    
    const is = require('is-0')

    console.log(is.empty('')) // true
    console.log(is.empty([])) // true
    console.log(is.empty({})) // true
    console.log(is.empty(null)) // true
    console.log(is.empty(undefined)) // true

    console.log(is.empty('hello')) // false
    console.log(is.empty([1, 2, 3])) // false
    console.log(is.empty({ a: 1 })) // false
    import * as is from 'is-0'

    const value: any = ''
    if (is.empty(value)) {
    console.log('Value is empty')
    }

    주어진 값이 "empty"인지 확인합니다.

    Empty로 판단되는 값:

    • 빈 문자열: '', new String(), ``
    • 빈 배열: [], new Array()
    • 빈 객체: {}, new Object()
    • null
    • undefined

    Empty가 아닌 값:

    is.empty(1)           // false - 숫자
    is.empty('string') // false - 문자열
    is.empty([1]) // false - 배열 (요소 있음)
    is.empty({a: 1}) // false - 객체 (프로퍼티 있음)
    is.empty(true) // false - boolean
    is.empty(false) // false - boolean
    is.empty(new Date()) // false - Date 객체
    is.empty(new Map()) // false - Map 객체

    특수 케이스:

    is.empty(new Proxy({}, {}))  // true - 빈 Proxy는 empty로 판단
    

    더 많은 예제는 ./test/datas/empty.ts를 참고하세요.

    is.empty()의 별칭입니다. 동일하게 동작합니다.

    • Node.js ≥ 20.0.0
    • npm ≥ 10.0.0

    기여를 환영합니다! 자세한 내용은 CONTRIBUTING.md를 참고하세요.

    MIT © SangHak Lee