New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seng-disposable

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seng-disposable

Disposable provides a common interface for disposing of objects

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Travis Code Climate Coveralls npm npm

seng-disposable

seng-disposable provides a basic framework for disposable classes and objects. Disposable is used as a basis for many Seng libraries because it provides a common interface which can be passed around to be disposed at a later time.

Installation

npm i -S seng-disposable

Or grab one of the following files from the /dist/ folder for manual use:

  • umd (bundled with webpack)
  • amd (bundled with webpack)
  • commonjs2 (bundled with webpack, but why don't you use npm?)
  • browser (bundled with webpack, available as window.SengDisposable)
  • system
  • es6

Usage

import Disposable from 'seng-disposable';

class AsyncThinger extends Disposable {
	interval:number;

	start() {
		this.interval = setInterval(() => console.log('hello world!'));
	}
	
	dispose() {
		if (this.interval !== void 0) {
			clearInterval(this.interval);
			this.interval = void 0;
		}
		
		super.dispose();
	}
}

// since all objects implementing IDisposable provide the same way to dispose it, we can simply create an array
// that contains IDisposable objects, without having to care about what they actually are.
let disposables:Array<IDisposable> = [];

disposables.push(new AsyncThinger());
disposables.push(new AsyncThinger());
disposables.push(new AsyncThinger());
disposables.push(new AsyncThinger());

disposables.forEach(disposable => disposable.dispose());

Documentation

View the generated documentation.

Building

In order to build seng-disposable, ensure that you have Git and Node.js installed.

Clone a copy of the repo:

git clone https://github.com/MediaMonks/seng-disposable.git

Change to the seng-disposable directory:

cd seng-disposable

Install dev dependencies:

npm install

Use one of the following main scripts:

npm run build   		# build this project (done on install)
npm run typings			# install .d.ts dependencies (done on install)
npm test    			# run the tests
npm validate			# runs validation scripts, including test, lint and doc
npm run lint			# run tslint on this project
npm run doc				# generate typedoc and yuidoc documentation
npm run typescript-npm	# just compile the typescript output used in the npm module

When installing this module, it adds a pre-commit hook, that runs the validate and build scripts before committing, so you can be sure that everything checks out and all files that should be committed are generated.

Contribute

View CONTRIBUTING.md

Changelog

View CHANGELOG.md

Authors

View AUTHORS.md

LICENSE

MIT © MediaMonks

Keywords

FAQs

Package last updated on 27 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc