Giter Club home page Giter Club logo

attachable's Introduction

npm version Build Status Coverage Status Code Climate Inch CI

Dependency Status devDependency Status

attachable

Simple object to bidirectionally track its attachments (links,connections) to other attachable objects

You can

obj1.attachTo(obj2)

And later

console.log( obj2.isAttachedTo(obj1) );
// true

If you have different needs regarding the functionality, please add a feature request.

Installation

npm install --save attachable

Usage

// var attachable=require('attachable');
var attachable=require('./index.js');
var obj1={}; attachable(obj1);
var obj2={}; attachable(obj2);

obj1.attachTo(obj2);

obj2.isAttachedTo(obj1);
// true
obj1.isAttachedTo(obj2);
// true

obj2.detachFrom(obj1)
obj2.isAttachedTo(obj1);
// false
obj1.isAttachedTo(obj2);
// false

Methods

attachTo(attachable)

Attach to specific attachable object (and also attach that object to this one)

detachFrom(attachable)

Detach from specific attachable object (and also attach that object from this one)

detachAll() 

Detach object from all currently attached attachable objects

boolean hasAttached()

Allows to check if this object has other attachable objects attached to it (it is attached to some other attachable objects)

boolean isAttachedTo(attachable)

Allows to check if the object attached to another attachable object

Credits

Alexander

Links to package pages:

github.com   npmjs.com   travis-ci.org   coveralls.io   inch-ci.org

License

MIT

attachable's People

Contributors

alykoshin avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.