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 🙏

© 2025 – Pkg Stats / Ryan Hefner

lightkit

v0.0.2

Published

A commonly used lightweight utility library

Downloads

6

Readme

LightKit

NPM Version NPM Downloads NPM License

This is a small and lightweight utility library that brings together commonly used functions during development. While there are already many major and excellent libraries available, they often include a lot of unused methods. Therefore, we are developing this library by focusing on only the essential features, keeping it lightweight.

Install

$ npm install lightkit

All Methods

All the methods provided so far are listed below.

Array

multiFilter

Filters an array using multiple filter functions and returns the filtered results in separate arrays.

import { multiFilter } from "lightkit"

const array = [1, 2, 3, 4, 5, 6]
const filters = [
  (n) => n % 2 === 0, // Filter even numbers
  (n) => n % 2 !== 0 // Filter odd numbers
]
const result = multiFilter(array, filters)

console.log(result)
// [[2, 4, 6], [1, 3, 5]]

asyncMap

Returns a Promise that resolves with a new array containing the results of asynchronously applying the mapping function to each element.

import { asyncMap } from "lightkit"

const array = [1, 2, 3, 4]
const asyncFnc = (d: number): Promise<number> => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(d * d)
    }, 100)
  })
}

const result = await asyncMap(array, async (n) => {
  return await asyncFnc(n)
})

console.log(result)
// [1, 4, 9, 16]

groupBy

Groups the elements of an array based on the specified key.
The elements must be objects, and the key must exist in the objects.

import { groupBy } from "lightkit"

const array = [
  { name: "Alice", age: 25 },
  { name: "Bob", age: 30 },
  { name: "Charlie", age: 25 }
]
const result = groupBy(array, "age")

console.log(result)
// {
//   "25": [ { name: 'Alice', age: 25 }, { name: 'Charlie', age: 25 } ],
//   "30": [ { name: 'Bob', age: 30 } ]
// }

groupAndSort

Groups the elements of an array based on the specified key and sorts the resulting groups using a custom comparator.

import { groupAndSort } from "lightkit"

const array = [
  { name: "Alice", age: 25 },
  { name: "Bob", age: 30 },
  { name: "Charlie", age: 25 }
]
const result = groupAndSort(
  array,
  "age",
  (a, b) => (a as number) - (b as number)
)

console.log(result)
// [
//   { age: 25, data: [ { name: 'Alice', age: 25 }, { name: 'Charlie', age: 25 } ] },
//   { age: 30, data: [ { name: 'Bob', age: 30 } ] }
// ]

Date

Constructor

Initializes the class with a given date value or the current date if no value is provided.

The LDate class also supports the "YYYY-MM-DD HH:MM:SS" format as a local date.

import { LDate } from "lightkit"

const instance1 = new LDate()
// Initializes with the current date and time.
const instance2 = new LDate(1629918000000)
// Initializes with a timestamp.
const instance3 = new LDate("2023-08-27T10:15:00Z")
// Initializes with a valid date string.
const instance4 = new LDate("2023-08-27 10:15:00")
// Initializes with a custom date string.
const instance5 = new LDate(new Date())
// Initializes with a Date object.

getDate

Retrieves the current date.

import { LDate } from "lightkit"

const dateString = "2023-08-27T10:15:00Z"
const dateTime = new Date(dateString).getTime()
const lDateTime = new LDate(dateString).getDate().getTime()

console.log(new LDate(dateString).getDate() instanceof Date) // true
console.log(dateTime === lDateTime) // true

getDateParts

Extracts various date and time properties from the Date object.

import { LDate } from "lightkit"

const dateString = "2023-08-27 15:30:45"
const dateProperties = new LDate(dateString).getDateParts("en")

console.log(dateProperties)
// {
//   year: '2023',
//   month: '08',
//   day: '27',
//   hour: '15',
//   minute: '30',
//   second: '45',
//   yearMonthDay: '2023-08-27',
//   yearMonth: '2023-08',
//   monthDay: '08-27',
//   hourMinuteSecond: '15:30:45',
//   hourMinute: '15:30',
//   dayOfWeek: 0,
//   dayOfWeekLong: 'Sunday',
//   dayOfWeekShort: 'Sun',
//   longTime: 1693117845000
// }

differenceIn

Calculates the difference between the current date and the provided date in the specified unit.

import { LDate } from "lightkit"

const lDate = new LDate("2023-01-01T00:00:00Z")
const targetDate = new Date("2024-01-01T00:00:00Z")

const diffInYears = lDate.differenceIn(targetDate, "year")
console.log(diffInYears) // 1

const diffInMonths = lDate.differenceIn(targetDate, "month")
console.log(diffInMonths) // 2

const diffInDays = lDate.differenceIn(targetDate, "day")
console.log(diffInDays) // 365

const diffInHours = lDate.differenceIn(targetDate, "hour")
console.log(diffInHours) // 8760

const diffInMinutes = lDate.differenceIn(targetDate, "minute")
console.log(diffInMinutes) // 525600

const diffInSeconds = lDate.differenceIn(targetDate, "second")
console.log(diffInSeconds) // 31536000