1.0.1 • Published 6 years ago

simple-resource-pool v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

simple-resource-pool

A simple resource pool implementation in typescript.

Installation

To use with node or a bundler:

$ npm install resource-pool

Directly in the browser:

<script src="path/to/yourCopyOf/simple-resource-pool.js"></script>

or using the minified version:

<script src="path/to/yourCopyOf/simple-resource-pool.min.js"></script>

or from UNPKG:

<script src="https://unpkg.com/simple-resource-pool@[version]/dist/simple-resource-pool.min.js"></script>

Typings

Included for Typescript in index.d.ts

Usage

import { ResourcePool } from 'simple-resource-pool'

import { MyResource } from './MyResource'

interface MyResource {
  foo: baz
}

const creator = () => new MyResource()

const rp = new ResourcePool<MyResource>(creator)

rp.getRes().then(res => {
  // ...do stuff with res...
  // ...
  // then release the resource
  rp.release(res)
})

Documentation

Pending

Also since this package is in UNPKG you can use dynamic-cdn-webpack-plugin with it.

Build

npm run build simply runs webpack using the included configuration file. Creates a universal module in the lib/ directory.

Linting

npm run lint

Running The Test Suite

Run the tests:

# npm run test