npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@baronote/tool

v0.0.15

Published

Baronote Utility

Downloads

67

Readme

@Baronote/tool

바로노트 공통 함수 모음 라이브러리로 다음과 같은 기능을 포함하고 있습니다.

Current Version : 0.0.15

설치

# NPM 
npm i @baronote/tool

목차


Array

Array 데이터에 사용 가능한 함수


isLengthZero

배열의 길이가 0인지 확인

/**
 * 
 * @param array // default : []
 * @returns {boolean}
 * 
 */

import isLengthZero from '@baronote/tool/array/isLengthZero.js';

console.log(isLengthZero([]))           // true
console.log(isLengthZero(['','']))      // false

or
import array from '@baronote/too/array/index.js';

console.log(array.isLengthZero([]))         // true
console.log(array.isLengthZero(['','']))    // false 

Format

값의 포멧을 변환하는 함수


byteToString

Byte Number 를 String 포멧으로 변환 Max Type -> Yotta (YB)

/**
 * 
 * @param number // default : null
 * @returns {string}
 * 
 */

import byteToString from '@baronote/tool/format/byteToString.js';
or
import format from '@baronote/tool/format/index.js';

console.log(byteToString(1024));                    // 1 KB
console.log(byteToString(10240));                   // 10 KB
console.log(byteToString(102400));                  // 100 KB
console.log(byteToString(10240000));                // 9.77 MB
console.log(byteToString(10240000000));             // 9.54 GB
console.log(byteToString(10240000000000));          // 9.31 TB

console.log(format.byteToString('1024'));           // 1KB 
console.log(format.byteToString('example'));        // 0 Byte
console.log(format.byteToString(''));               // 0 Byte

longTimeToStringTime

Long 형 TimeStamp 를 String Format 으로 변경 형식에 맞지 않는 경우 '' (공백) 반환

/**
 * 
 * @param number // default : null
 * @param string // default : 'yyyy-mm-dd HH:MM:ss'
 * @returns {string}
 * 
 */

import longTimeToStringTime from '@baronote/tool/format/longTimeToStringTime.js';

console.log( longTimeToStringTime());                               // ''
console.log( longTimeToStringTime(''));                             // ''
console.log( longTimeToStringTime(true));                           // ''
console.log( longTimeToStringTime(1670552431662));                  // 2022-12-09 11:20:31
console.log( longTimeToStringTime(1670552431662, 'yyyy-mm-dd'));    // 2022-12-09

stringTimeToLongTime

String 형 TimeStamp 를 Long Timestamp로 변경 형식에 맞지 않는 경우 0 반환

/**
 * 
 * @param string // default : null
 * @returns {number}
 * 
 */

import stringTimeToLongTime from '@baronote/tool/format/stringTimeToLongTime.js';

console.log( stringTimeToLongTime());                                                       // 0
console.log( stringTimeToLongTime(''));                                                     // 0
console.log( stringTimeToLongTime(true));                                                   // 0
console.log( stringTimeToLongTime('1670552431000'));                                        // 0
console.log( stringTimeToLongTime(1670552431000));                                          // 0
console.log( stringTimeToLongTime('2022-12-09 11:20:31'));                                  // 1670552431000
console.log( stringTimeToLongTime('Fri Dec 09 2022 11:57:07 GMT+0900 (한국 표준시)'));      // 1670554627000

Object

객체형 데이터에 사용 가능한 함수


hasOwnProperty

Object 안에 Key 가 존재하는지 확인 ESLint - prefer-object-has-own 충족되는 함수

/**
 * 
 * @param object // default : null
 * @param string // default : null
 * @returns {boolean}
 * 
 */

import hasOwnProperty from '@baronote/tool/object/hasOwnProperty.js';
or
import object from '@baronote/tool/object/index.js';

const exampleObject = {
    'example' : 'value'
};

console.log(hasOwnProperty(exampleObject,'example'))        // true
console.log(hasOwnProperty(exampleObject,'example2'))       // false

console.log(hasOwnProperty(undefined));                     // false
console.log(hasOwnProperty(exampleObject));                 // false

toString

Any 객체 값의 타입을 String 형태로 반환

/**
 * 
 * @param Any // default : null
 * @returns {String}
 * 
 */

import hasOwnProperty from '@baronote/tool/object/toString.js';
or
import object from '@baronote/tool/object/index.js';

console.log(toString({}));              // [object Object]
console.log(toString(null));            // [object Null]
console.log(toString(undefined));       // [object Undefined]
console.log(toString([]));              // [object Array]
console.log(toString(123));             // [object Number]
console.log(toString('example'));       // [object String]

Type

값의 타입이 맞는지 확인 하는 함수 모음


isArray

파라미터가 배열 형태가 맞는지 확인

/**
 * 
 * @param array // default : null
 * @returns {boolean}
 * 
 */

import isArray from '@baronote/tool/type/isArray.js';
or
import type from '@baronote/tool/type/index.js';

console.log(isArray([]));           // true
console.log(isArray(['']));         // true
console.log(isArray({}));           // false
console.log(isArray(''));           // false
console.log(isArray(123));          // false
console.log(isArray(undefined));    // false
console.log(isArray(null));         // false
console.log(isArray(NaN));          // false

isBoolean

파라미터가 불린 형태가 맞는지 확인

/**
 * 
 * @param boolean // default : null
 * @returns {boolean}
 * 
 */

import isBoolean from '@baronote/tool/type/isBoolean.js';

console.log(isBoolean(true));           // true
console.log(isBoolean(false));          // true
console.log(isBoolean([]));             // false
console.log(isBoolean(['']));           // false
console.log(isBoolean({}));             // false
console.log(isBoolean(''));             // false
console.log(isBoolean(123));            // false
console.log(isBoolean(undefined));      // false
console.log(isBoolean(null));           // false
console.log(isBoolean(NaN));            // false

isNumber

파라미터가 숫자 형태가 맞는지 확인 NaN 값인 경우에도 false 로 구성 되었습니다.

/**
 * 
 * @param Number // default : null
 * @returns {boolean}
 * 
 */

import isNumber from '@baronote/tool/type/isNumber.js';

console.log(isNumber(123));            // true
console.log(isNumber(NaN));            // false
console.log(isNumber(true));           // false
console.log(isNumber(false));          // false
console.log(isNumber([]));             // false
console.log(isNumber(['']));           // false
console.log(isNumber({}));             // false
console.log(isNumber(''));             // false
console.log(isNumber(undefined));      // false
console.log(isNumber(null));           // false

isDate

파라미터의 형태가 Date로 변환이 가능한지 확인 Boolean, int 값인 경우에도 true 로 구성 되었습니다.

/**
 * 
 * @param Number // default : null
 * @returns {boolean}
 * 
 */

import isDate from '@baronote/tool/type/isDate.js';

console.log(isDate(true));                                                  // true
console.log(isDate(false));                                                 // true
console.log(isDate(123));                                                   // true
console.log(isDate(1670552431662));                                         // true
console.log(isDate('Fri Dec 09 2022 11:25:31 GMT+0900 (한국 표준시)'));     // true
console.log(isDate('Fri '));                                                // false
console.log(isDate([]));                                                    // false
console.log(isDate({}));                                                    // false
console.log(isDate(NaN));                                                   // false
console.log(isDate(undefined));                                             // false

그 외 Type 함수 모음

위와 동일한 방법의 사용으로 축약하여 기록

  • isFunction
  • isObject
  • isString
  • isUndefined

함수를 추가하거나 요청사항은 Baronote 에서 가능합니다.