open-index/open-npm huggingface dataset:
npm package: @hscmap/inertial-mouse
Description: Inertial Mouse for TypeScript * Wraps native MouseEvent and emit pseudo mousemove events with inertial smooth motion. * [Working Demo](https://michitaro.github.io/inertial-mouse)
Latest version: 3.5.0
Deprecated: no longer maintained

# Inertial Mouse
Inertial Mouse for TypeScript
* Wraps native MouseEvent and emit pseudo mousemove events with inertial smooth motion.
* [Working Demo](https://michitaro.github.io/inertial-mouse)

## Install

```sh
npm instasll --save @hscmap/inertial-mouse
```

## Example (source code of the working demo)

```typescript
import { InertialMouse, V2 } from "@hscmap/inertial-mouse"


window.addEventListener('load', e => {
    const sandbox = document.querySelector('.sandbox') as HTMLElement
    const cursor = document.querySelector('.cursor') as HTMLElement
    const dxText = document.querySelector('[name="dx"]') as HTMLInputElement
    const dyText = document.querySelector('[name="dy"]') as HTMLInputElement

    function setCursorPosition(r: V2) {
        cursor.style.left = `${r.x}px`
        cursor.style.top = `${r.y}px`
    }

    const im = new InertialMouse(sandbox, {
        down: (e) => {
            setCursorPosition(e.r)
            cursor.classList.add('pressed')
        },
        up: () => {
            cursor.classList.remove('pressed')
        },
        move: (e) => {
            setCursorPosition(e.r)
            dxText.value = `${e.d.x}`
            dyText.value = `${e.d.y}`
        },
        movestart: () => cursor.classList.add('moving'),
        moveend: () => cursor.classList.remove('moving'),
    })

    document.addEventListener('keydown', e => im.stop())

    document.addEventListener('change', e => {
        const target = e.target as HTMLInputElement
        if (target.matches('[name="slick"]'))
            im.physics.slick = target.checked
        if (target.matches('[name="friction"]'))
            im.physics.friction = Number(target.value)
        if (target.matches('[name="k"]'))
            im.physics.k = Number(target.value)
    })
})


document.addEventListener('selectstart', e => e.preventDefault()) // disable selection```
npm package: @hscmap/inertial-wheel
Description: * InertialWheel wraps native WheelEvent and emits pseudo wheel events with inertial motion. * [Working Demo](https://michitaro.github.io/inertial-wheel)
Latest version: 0.6.6
Deprecated: no longer maintained

# InertialWheel
* InertialWheel wraps native WheelEvent and emits pseudo wheel events with inertial motion.
* [Working Demo](https://michitaro.github.io/inertial-wheel)

## Install

```sh
npm instasll --save @hscmap/inertial-wheel
```

## Example (source code of the working demo)

```typescript
import { InertialWheel } from "@hscmap/inertial-wheel"


window.addEventListener('load', e => {
    const trackpad = document.querySelector('.trackpad') as HTMLDivElement

    const inertialWheelEventHistory = new HistoryCanvas(document.querySelector('#inertial-event-history') as HTMLCanvasElement)
    new InertialWheel(trackpad, {
        wheel: e => inertialWheelEventHistory.push(e.v),
        wheelstart: e => inertialWheelEventHistory.canvas.classList.add('active'),
        wheelend: e => inertialWheelEventHistory.canvas.classList.remove('active'),
    })

    const nativeEventHistory = new HistoryCanvas(document.querySelector('#native-event-history') as HTMLCanvasElement)
    trackpad.addEventListener('wheel', e => {
        e.preventDefault()
        nativeEventHistory.push(e.deltaY)
    })
})


class HistoryCanvas {
    private ctx: CanvasRenderingContext2D
    private ys: number[] = []

    constructor(readonly canvas: HTMLCanvasElement) {
        this.initCanvas()
        this.refresh()
    }

    private initCanvas() {
        this.canvas.width = 500
        this.canvas.height = 200
        this.ctx = this.canvas.getContext('2d')!
    }

    push(y: number) {
        this.ys.unshift(y)
        this.ys.splice(this.canvas.width)
        this.refresh()
    }

    private refresh() {
        const ctx = this.ctx
        const canvas = this.canvas
        const y0 = this.canvas.height / 2

        ctx.clearRect(0, 0, canvas.width, canvas.height)

        ctx.strokeStyle = '#777'
        ctx.beginPath()
        ctx.lineTo(0, y0)
        ctx.lineTo(this.canvas.width, y0)
        ctx.stroke()

        ctx.strokeStyle = 'rgba(255, 0, 0, 0.5)'
        ctx.beginPath()
        for (let i = 0; i < this.ys.length; ++i)
            ctx.lineTo(i, this.ys[i] + y0)
        ctx.stroke()
    }
}
```
npm package: @hscmap/keybind
Description: This module provide a way for listening for key combination events with simple API.
Latest version: 0.2.0

# Keybind
This module provide a way for listening for key combination events with simple API.

# Example (Source of the working demo)

* [Working DEMO](http://michitaro.github.io/keybind)

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

window.addEventListener('load', () => {
    keybind.on('shift+x', () => alert('shift + X'))
    keybind.on('alt+x', () => alert('alt + X'))
    keybind.on('ctrl+x', () => alert('ctrl + X'))
    keybind.on('meta+x', () => alert('meta + X'))

    // can be triggered only once
    const off = keybind.on('shift+ctrl+x', () => {
        alert('shift + ctrl + X (triggered only once)')
        off()
    })

    const sources = ['shift+x', 'alt+x', 'ctrl+x', 'meta+x', 'shift+ctrl+x']
    for (const s of sources) {
        const html = keybind.html(s)
        const div = document.createElement('div')
        div.innerHTML = html
        document.body.appendChild(div)
    }
})
```
npm package: @hscmap/linear-fit
Description: * High performance linear fit * [Working Demo](https://michitaro.github.io/linear-fit)
Latest version: 0.0.0

# Linear Fit
* High performance linear fit
* [Working Demo](https://michitaro.github.io/linear-fit)

## Install

```sh
npm instasll --save @hscmap/linear-fit
```

## Example (source code of the working demo)

```typescript
import { linearFit } from "@hscmap/linear-fit"


window.addEventListener('load', e => {
    const canvas = document.querySelector('canvas')!
    const ctx = canvas.getContext('2d')!

    const samples = generateRandomPoints(canvas)
    for (const [x, y] of samples) {
        ctx.fillRect(x, y, 1, 1)
    }

    const [a0, a1, a2] = linearFit(samples)
    ctx.strokeStyle = '#f00'
    ctx.beginPath()
    for (let x = 0; x < canvas.width; ++x) {
        const y = a0 + a1 * x + a2 * x ** 2
        ctx.lineTo(x, y)
    }
    ctx.stroke()
})


function generateRandomPoints(size: { width: number, height: number }) {
    const samples: [number, number][] = []
    const w0 = Math.random() - 0.5
    const c = Math.random() * 0.5
    for (let i = 0; i < 800; ++i) {
        const x = size.width * Math.random()
        const w = 2 * (x / size.width) - 1
        const y = 0.5 * size.height * ((w - w0) ** 2 + 0.2 * Math.random() + c)
        samples.push([x, y])
    }
    return samples
}
```
npm package: @hscmap/magic-trackpad-detector
Description: * Apple's Magic trackpad emits *pseudo inertial* scroll event. This module determines wheter a wheel event is a **real** event (generated by a user's action) or a **pseudo inertial** event. * [Working Demo](https://michitaro.github.io/magic-trackpad-detec
Latest version: 0.0.9

# Magic Trackpad's inertial scroll Detector
* Apple's Magic trackpad emits *pseudo inertial* scroll event. This module determines wheter a wheel event is a **real** event (generated by a user's action) or a **pseudo inertial** event.
* [Working Demo](https://michitaro.github.io/magic-trackpad-detector)

![screenshot](screenshot.png)

## Install

```sh
npm instasll --save @hscmap/magic-trackpad-detector
```

## Example (source code of the working demo)

```typescript
import { MagicTrackpadDetector } from "@hscmap/magic-trackpad-detector"


window.addEventListener('load', e => {
    const trackpad = document.querySelector('.trackpad') as HTMLDivElement
    const canvas = document.querySelector('canvas') as HTMLCanvasElement

    const history: [number, boolean][] = []
    const mtd = new MagicTrackpadDetector()
    const historyCanvas = new HistoryCanvas(history, canvas)

    trackpad.addEventListener('wheel', e => {
        e.preventDefault()
        history.unshift([e.deltaY, mtd.inertial(e)])
        if (history.length > canvas.width)
            history.splice(canvas.width)
        historyCanvas.refresh()
    })

    historyCanvas.refresh()
})


class HistoryCanvas {
    private ctx: CanvasRenderingContext2D
    private w: number
    private h: number

    constructor(private history: [number, boolean][], canvas: HTMLCanvasElement) {
        this.ctx = canvas.getContext('2d')!
        this.w = canvas.width
        this.h = canvas.height
    }

    refresh() {
        this.clear()
        this.drawInertialAreas()
        this.drawAxis()
        this.drawHistory()
    }

    private clear() {
        this.ctx.clearRect(0, 0, this.w, this.h)
    }

    private drawInertialAreas() {
        const ctx = this.ctx
        let state = false
        let start: number
        this.history.push([0, false])
        for (let x = 0; x < this.history.length; ++x) {
            const [, i] = this.history[x]
            if (state != i) {
                if (state = i)
                    start = x
                else {
                    ctx.fillStyle = '#ccf'
                    ctx.fillRect(start!, 0, x - start, this.h)
                }
            }
        }
        this.history.pop()
    }

    private drawHistory() {
        const ctx = this.ctx
        ctx.strokeStyle = '#f00'
        ctx.beginPath()
        for (let x = 0; x < this.history.length; ++x) {
            const [y,] = this.history[x]
            ctx.lineTo(x, y + this.h / 2)
        }
        ctx.stroke()
    }

    private drawAxis() {
        const ctx = this.ctx
        ctx.beginPath()
        ctx.strokeStyle = '#777'
        ctx.lineTo(0, this.h / 2)
        ctx.lineTo(this.w, this.h / 2)
        ctx.stroke()
    }
}
```
npm package: @hscmap/quadratic-fit
Description: * High performance quadratic fit * [Working Demo](https://michitaro.github.io/quadratic-fit)
Latest version: 0.0.0

# Quadratic Fit
* High performance quadratic fit
* [Working Demo](https://michitaro.github.io/quadratic-fit)

## Install

```sh
npm instasll --save @hscmap/quadratic-fit
```

## Example (source code of the working demo)

```typescript
import { quadraticFit } from "@hscmap/quadratic-fit"


window.addEventListener('load', e => {
    const canvas = document.querySelector('canvas')!
    const ctx = canvas.getContext('2d')!

    const samples = generateRandomPoints(canvas)
    for (const [x, y] of samples) {
        ctx.fillRect(x, y, 1, 1)
    }

    const [a0, a1, a2] = quadraticFit(samples)
    ctx.strokeStyle = '#f00'
    ctx.beginPath()
    for (let x = 0; x < canvas.width; ++x) {
        const y = a0 + a1 * x + a2 * x ** 2
        ctx.lineTo(x, y)
    }
    ctx.stroke()
})


function generateRandomPoints(size: { width: number, height: number }) {
    const samples: [number, number][] = []
    const w0 = Math.random() - 0.5
    const c = Math.random() * 0.5
    for (let i = 0; i < 800; ++i) {
        const x = size.width * Math.random()
        const w = 2 * (x / size.width) - 1
        const y = 0.5 * size.height * ((w - w0) ** 2 + 0.2 * Math.random() + c)
        samples.push([x, y])
    }
    return samples
}
```
npm package: @hscmap/stellar-globe
Description: * Web-based viewer for all sky survey.
Latest version: 0.6.19

## Introduction
* Web-based viewer for all sky survey.

## Build
1. Install [Node](https://nodejs.org)
    * needed for running build tools.
1. Clone this repository
    ```sh
    git clone https://github.com/michitaro/stellar-globe
    cd stellar-globe
    ```
1. Download external libraries
    ```sh
    npm install
    ```
1. Run development local server
    ```sh
    npm run example-server
    ```
    * Open http://localhost:8080/
    * To change image repository, edit [here](https://github.com/michitaro/stellar-globe/blob/master/example/main.ts#L18)
npm package: @hscmap/tuple-map
Description: <!-- TupleMapはほとんどES6のMapと同じですが、tupleをキーに持つことができます。 --> TupleMap is almost same as a ES6's Map, but it can have tuples as its keys.
Latest version: 0.0.3

# TupleMap

<!-- TupleMapはほとんどES6のMapと同じですが、tupleをキーに持つことができます。 -->
TupleMap is almost same as a ES6's Map, but it can have tuples as its keys.

## Install
```sh
npm install --save @hscmap/tuple-map
```

## Example

```typescript
import { TupleMap } from "@hscmap/tuple-map"

const tm = new TupleMap<[number, number], string>()

console.assert(tm.get([0, 0]) == undefined)

tm.set([0, 0], '0,0')
console.assert(tm.get([0, 0]) == '0,0')
console.assert(tm.get([0, 1]) == undefined)

tm.delete([0, 0])
console.assert(tm.get([0, 0]) == undefined)

tm.set([1, 2], '1,2')
tm.set([1, 2], '1,2')
console.assert(tm.has([1, 2]))
console.assert(tm.get([1, 2]) == '1,2')

tm.delete([1, 2])
console.assert(tm.has([1, 2]) == false)
console.assert(tm._internalMapSize() == 0)


tm.set([1, 2], '1,2')
tm.clear()
console.assert(tm.get([1, 2]) == undefined)
```