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

util-kit

v0.1.4

Published

An util package both for browser and nodejs, mainly reorganized from the vscode's code base snippet, and make vscode's some internal utilities available for your own project.

Downloads

43

Readme

util-kit

util-kit is mainly from vscode's code base snippet, and it is an util npm both for browser and nodejs. What util-kit has done:

  1. Organize the vscode snippet as a util npm can be used both on browser and nodejs. And re-organize the exports of vscode snippet for easily usage.
  2. add documents for utitilies. For complex utitilies, documents and exmaples are provided. For other easy ones, you can easily find the interface in typescript environment.

As a fan for vscode, I think vscode is the most awesome open source front-end project I've ever seen, and its code base has realy high quality. So I think What if we can reuse all this good stuff (the elegant data structure / algrithom / design pattern in vscode) in our own project? Maybe it is a good idea. So util-kit is created fot this purpose, I hope it can be helpful.

The source code of vscode:

  • src/vs/base/common This part is common utility part, and it can be run both in browser and nodejs.

unit test:

The code base will be synced from vscode monthly.

How To Use util-kit

npm install --S util-kit

Available Utilities

1. lifecycle ( Disposable )

Disposable is an important concept in vscode, used to manage the lifecycle of object. Disposable is an abstract class, which can not be instanced. So many objects in vscode are disposable. Especiallly, the event-related part use it a lot. Dispose has the same meaning as destroy.

import { 
  IDisposable, DisposableStore, dispose, isDisposable, 
  combinedDisposable, toDisposable, 
} from 'util-kit';

Actually it does not do much work in disposable itself, it should be considered as sth like coding rule in vscode. For details, you can easily find the interface in typescript environment.

2. Event ( Emitter )

The event-related utils can be found in util-kit as below:

import { 
	Emitter, PauseableEmitter, AsyncEmitter,
	EventBufferer, EventMultiplexer, 
	Event, 
	CancellationToken, asyncs,
	IWaitUntil,
} from 'util-kit';

The Event (Emitter) in vscode has the following features:

  1. Emitter ( Emitter/PauseableEmitter/AsyncEmitter ) :
    • No Event Name Concept
    • Handling Exception in event handler
    • In-Order delivery, especially in the scenarior of firing event in handler
  2. PauseableEmitter (extends Emitter)
  3. AsyncEmitter (extends Emitter)
  4. EventMultiplexer ( an util class for emitter)
  5. EventBufferer ( an util class for emitter)
  6. Event Utils ( util functions under the namespace Event)
    • Event.buffer
    • Event.latch
    • Event.once
    • Event.stopwatch
    • Event.fromPromise
    • Event.debounce

For details, Please view Event (Emitter) document.

3. objects

import { objects } from 'util-kit';
const {
  deepClone, deepFreeze, cloneAndChange, mixin, equals, 
  safeStringify, getOrDefault, distinct, getCaseInsensitive, 
} = objects;

4. numbers

import { numbers } from 'util-kit';
const {
  clamp, rot, Counter, MovingAverage 
} = numbers;

5. strings

import { strings } from 'util-kit';
const {
  clamp, rot, Counter, MovingAverage 
} = strings;

6. dates

7. decorators

import { decorators } from 'util-kit';
const {
  createDecorator, createMemoizer, memoize, debounce, throttle, 
} = decorators;

7. uuid