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

@focme/rsk-util

v1.0.3

Published

a tool lib for rsk-template

Downloads

8

Readme

@focme/rsk-util

a tool lib for rsk-template

functions

is

is.nil
param

  • target: any

returns boolean

determine target is undefined or null

import { is } from "@focme/rsk-util"

is.nil(undefined) // true
is.nil(null) // true
is.nil("") // false
is.nil(0) // false
is.nil(true) // false
is.nil({}) // false
is.nil([]) // false

is.nilEmpty
param

  • target: any

returns boolean

determine target is nil or empty string

import { is } from "@focme/rsk-util"

is.nilEmpty(undefined) // true
is.nilEmpty(null) // true
is.nilEmpty("") // true
is.nil(0) // false
is.nil(true) // false
is.nil({}) // false
is.nil([]) // false

fill

fill
param

  • option: { target, length, item, position }

    target: string target string
    length: number length of the result
    item: string the item filled into target
    position: start | end | around filling position default value end

returns string

import { fill } from "@focme/rsk-util"

fill() // ""
fill({ length: 10 }) // "          "
fill({ length: 10, item: "1" }) // "1111111111"
fill({ target: "6", length: 2, item: "0" }) // "60"
fill({ target: "6", length: 2, item: "0", position: "start" }) // "06"

createCurrent

createCurrent
param

  • init: any

returns { current: any }

a copy of React.useRef hook

import { createCurrent } from "@focme/rsk-util"

const current = createCurrent(0)
console.log(current) // { current: 0 }

createJoin

createJoin
param

  • separator: string

returns (...arg[]: any[]) => string

a Array.prototyp.join.call function

const { createJoin } from "@focme/rsk-util"

const join = createJoin()
join([1, 3, 5, () => 7]) // `1357`
join("-") // `1-3-5-7`
const { createJoin } from "@focme/rsk-util"

const join = createJoin("-")
join([1, 3, 5, () => 7]) // `1-3-5-7`

createJoin.from
param

  • ...arg[]: any[]

returns (separator: string) => string

a Array.prototyp.join.call function

const { createJoin } from "@focme/rsk-util"

const join = createJoin.from([1, 3, 5, () => 7])
join() // `1357`
join("-") // `1-3-5-7`

createTimer

createTimer
returns { check, record, records, format }
> check() add a record
> record(index: number) get a record
> records() get all records
> format(template: string, index?: number) format a record to string

record durations

const createTimer from "@focme/rsk-util"

const timer = createTimer()
timer.record() // 0
setTimeout(() => {
    timer.check()
    timer.record() // may be 10
    timer.record(-1) // may be 10
    timer.record(0) // 0
    timer.records() // may be [0, 10]
    timer.format("ss\\s") // may be 10s
    timer.format("ss\\s", 0) // 0s
}, 10)

format option

|option|value |example(984224415)| |------|------------|------------------| |SSSS |duration |"984224415" | |SSS |milliseconds|"415" | |SS |full seconds|"984224" | |ss |seconds |"44" | |MM |full minutes|"16403" | |mm |minutes |"23" | |HH |full hours |"273" | |hh |hours |"9" | |dd |days |"11" |

createDater

createDater
param

  • date: Date

returns { current, format }

const { createDater } from "@focme/rsk-util"

const dater = createDater(new Date(1695019785071))
console.log(dater.current) // { YYYY, YY, ... }
dater.format("YYYY") // 2023
dater.format("YYYY-MM-DD HH:mm:ss") // "2023-09-18 14:49:45"

format option

|option|value |example(1695019785071)| |------|-------------------------------------|----------------------| |YYYY |Four-digit year |"2023" | |YY |Two-digit year |"23" | |MMMM |The full month name |"September" | |MMM |The abbreviated month name |"Sep" | |MM |The month, 2-digits |"09" | |M |The month, beginning at 1 |"9" | |DD |The day of the month, 2-digits |"18" | |D |The day of the month |"18" | |ddd |The name of the day of the week |"Monday" | |dd |The short name of the day of the week|"Mon" | |d |The day of the week, with Sunday as 0|"1" | |HH |The hour, 2-digits |"14" | |H |The hour |"14" | |hh |The hour, 12-hour clock, 2-digits |"02" | |h |The hour, 12-hour clock |"2" | |mm |The minute, 2-digits |"49" | |m |The minute |"49" | |SSS |The millisecond, 3-digits |"071" | |ss |The second, 2-digits |"45" | |s |The second |"45" | |A | |"PM" | |a | |"pm" | |ZZ |The offset from UTC, ±HHmm |"+0800" | |Z |The offset from UTC, ±HH:mm |"+08:00" |