open-index/open-npm huggingface dataset:
npm package: @hscmap/cache-map
Description: CacheMap is an Es6's Map-like collection class with a limit of number of items. The limit must be specified at initialization time. ## Install ```sh npm install --save @hscmap/cache-map ```
Latest version: 1.2.0

# Introduction
CacheMap is an Es6's Map-like collection class with a limit of number of items.
The limit must be specified at initialization time.
## Install
```sh
npm install --save @hscmap/cache-map
```

## Example
```typescript
import { CacheMap } from "@hscmap/cache-map"
import * as _ from 'lodash'


const assert = (test: boolean) => console.assert(test)


!(function withoutPersistentItem() {
    const dropLog: number[] = []
    const cm = new CacheMap<string, number>(3, v => dropLog.push(v))

    cm.set('one', 1)
    cm.set('two', 2)
    cm.set('three', 3)

    assert(cm.get('one') == 1)
    assert(cm.get('two') == 2)
    assert(cm.get('three') == 3)

    cm.set('four', 4)
    assert(cm.get('four') == 4)
    assert(cm.get('one') == undefined)

    assert(cm.get('two') == 2)
    cm.set('five', 5)
    assert(cm.peek('two') == 2)
    assert(cm.peek('three') == undefined)

    assert(cm.size == 3)
    assert(_.isEqual(dropLog, [1, 3]))

    cm.clear()
    assert(cm.size == 0)
    assert(_.isEqual(dropLog, [1, 3, 4, 2, 5]))

    cm.set('one', 1)
    cm.set('two', 2)

    cm.delete('one')
    assert(cm.get('one') == undefined)
    assert(cm.size == 1)

})()


!(function test2() {
    const dropLog: number[] = []
    const cm = new CacheMap<string, number>(3, v => dropLog.push(v))

    cm.set('one', 1, true)
    cm.set('two', 2)
    cm.set('three', 3, true)
    cm.set('four', 4)
    cm.set('five', 5)
    cm.set('six', 6)
    cm.set('seven', 7)
    assert(cm.peek('one') == 1)
    assert(cm.peek('two') == undefined)
    assert(cm.peek('three') == 3)
    assert(cm.peek('four') == undefined)
    assert(cm.size == 5)
    assert(_.isEqual(dropLog, [2, 4]))
})()
```
npm package: @hscmap/easing
Description: Simple easing functions for TypeScript * [Working Demo](https://michitaro.github.io/easing/)
Latest version: 0.0.0

# easing
Simple easing functions for TypeScript
* [Working Demo](https://michitaro.github.io/easing/)

## Install

```sh
npm instasll --save @hscmap/easing
```

## Example

```typescript
import * as easing from "@hscmap/easing"


window.addEventListener('load', e => {
    const fs = [
        easing.linear,
        easing.fastStart2, easing.fastStart4,
        easing.slowStart2, easing.slowStart4,
        easing.slowStartStop2,
        easing.slowStartStop4,
    ]

    for (const f of fs) {
        const box = document.createElement('div')
        box.className = 'box'
        const title = document.createElement('h2')
        title.innerHTML = f.name
        const canvas = document.createElement('canvas')
        drawFunction(canvas, f)
        box.appendChild(title)
        box.appendChild(canvas)
        document.body.appendChild(box)
    }
})


function drawFunction(canvas: HTMLCanvasElement, f: (x: number) => number) {
    function canvasCoord(x: number, y: number) {
        return [canvas.width * x, canvas.height * (1 - y)]
    }
    const ctx = canvas.getContext('2d')!
    ctx.beginPath()
    for (let x = 0; x <= 1; x += 0.01) {
        const y = f(x)
        const [X, Y] = canvasCoord(x, y)
        ctx.lineTo(X, Y)
    }
    ctx.stroke()
}
```
npm package: @hscmap/event-emitter
Description: EventEmitter for TypeScript
Latest version: 0.0.0
Deprecated: no longer maintained

# Event Emitter
EventEmitter for TypeScript

## Install
```sh
npm install --save @hscmap/event-emitter
```

## Example
```typescript
import { EventEmitter } from '@hscmap/event-emitter'


class MyEvent1 {
    constructor(readonly message: string) { }
}

class MyEvent2 {
    constructor(readonly message: string) { }
}


const ee = new EventEmitter()


const off1 = ee.on(MyEvent1, e => {
    throw e
})


ee.on(MyEvent2, e => {
    throw e
})


try {
    ee.emit(new MyEvent2('hello'))
    throw new Error()
}
catch (e) {
    console.assert(e instanceof MyEvent2)
    console.assert(e.message == 'hello')
}


try {
    ee.emit(new MyEvent1('world'))
    throw new Error()
}
catch (e) {
    console.assert(e instanceof MyEvent1)
    console.assert(e.message == 'world')
}


off1()


try {
    ee.emit(new MyEvent1('hello'))
    throw new Error('no handler fired')
}
catch (e) {
    console.assert(e instanceof Error && e.message == 'no handler fired')
}
```