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

ikeru

v2.7.3

Published

The art of arranging data

Downloads

16

Readme

ikeru

npm Build Status dependencies Status devDependencies Status

The art of arranging data

Usage

Install ikeru by running:

yarn add ikeru

BinarySearchTree

A sorted dictionary of number keys to arbitrary values.

Note that these trees do not self-balance. See RedBlackTree.

import { get, set, remove, entries } from 'ikeru/binary-search-tree'

let tree
tree = set(tree, 5, { title: 'Five' })
tree = set(tree, 3, { title: 'Three' })
tree = set(tree, 7, { title: 'Seven' })

console.log(get(tree, 1))
// null

for (const node of entries(tree)) {
  console.log(node.key, node.title)
  // 3, 'Three'
  // 5, 'Five'
  // 7, 'Seven'
}

console.log(JSON.stringify(tree, null, 2))
// {
//   "key": 5,
//   "value": {
//     "name": "Five"
//   },
//   "left": {
//     "key": 3,
//     "value": {
//       "name": "Three"
//     },
//     "left": null
//     "right": null
//   }
//   "right": {
//     "key": 7,
//     "value": {
//       "name": "Seven"
//     },
//     "left": null
//     "right": null
//   }
// }

tree = remove(tree, 5)

for (const node of entries(tree)) {
  console.log(node.key, node.value)
  // 3, { name: 'Three' }
  // 7, { name: 'Seven' }
}

RedBlackTree

A BinarySearchTree that self-balances after every update, maintaining O(log n) reads and writes.

RedBlackTree follows the same interface as BinarySearchTree.

import { get, set, remove, entries } from 'ikeru/red-black-tree'

let tree
tree = set(tree, 5, { title: 'Five' })
tree = set(tree, 3, { title: 'Three' })
tree = set(tree, 7, { title: 'Seven' })

for (const node of entries(tree)) {
  console.log(node.key, node.title)
  // 3, 'Three'
  // 5, 'Five'
  // 7, 'Seven'
}

TimeSeries

ikeru provides various utilities for summarizing and transforming time series data.

import {
  merge, downsample, interpolate, extrapolate, window, join
} from 'ikeru/time-series'
import {
  getMonth, startOfMonth, differenceInDays, addDays, addMonths, subMonths
} from 'date-fns'

const series1 = [
  { time: Date.parse('2019-01-01') },
  { time: Date.parse('2019-02-03') },
  { time: Date.parse('2019-03-07') }
]
const series2 = [
  { time: Date.parse('2019-01-02') },
  { time: Date.parse('2019-02-04') },
  { time: Date.parse('2019-03-08') }
]
const series3 = [
  { time: Date.parse('2019-01-05') },
  { time: Date.parse('2019-02-06') },
  { time: Date.parse('2019-03-09') },
  { time: Date.parse('2019-05-03') }
]

const series = merge(series1, series2, series3)

const monthlyMissingApril = downsample(
  series,
  point => startOfMonth(point.time).getTime(),
  (time, points) => ({ time })
)

const monthly = interpolate(
  monthlyMissingApril,
  (before, after) => {
    const newPoints = []
    let point = before
    while (differenceInDays(after.time, point.time) > 1) {
      point = {
        time: addDays(point.time, 1).getTime()
      }
      newPoints.push(point)
    }
    return newPoints
  }
)

const everyMonthInYear = extrapolate(
  monthly,
  start => {
    const newPoints = []
    let point = start
    while (getMonth(point.time) > 0) {
      point = subMonths(point, 1)
      newPoints.push(point)
    }
    newPoints.reverse()
    return newPoints
  },
  end => {
    const newPoints = []
    let point = end
    while (getMonth(point.time) < 11) {
      point = addMonths(point.time, 1)
      newPoints.push(point)
    }
    return newPoints
  }
)

const firstThreeMonths = window(
  everyMonthInYear,
  Date.parse('2019-01-01'),
  Date.parse('2019-03-31')
)


const parallelSeries1 = [
  { time: Date.parse('2019-01-01'), value: 1 },
  { time: Date.parse('2019-01-02'), value: 2 },
  { time: Date.parse('2019-01-03'), value: 3 }
]
const parallelSeries2 = [
  { time: Date.parse('2019-01-01'), value: 4 },
  { time: Date.parse('2019-01-02'), value: 5 },
  { time: Date.parse('2019-01-03'), value: 6 }
]
const addedUp = join([parallelSeries1, parallelSeries2], (time, [p1, p2]) => ({
  time,
  value: p1.value + p2.value
}))