0.0.1 • Published 6 years ago

data-factory v0.0.1

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

Data Factory Javascript

Manage data and stack easily with data-factory

Install

npm install --save data-factory

Usage

Create as much data that you need and manage them in one instance.

const dataFactory = require('data-factory');

var data = new dataFactory;

data.set('Wait why ? I have not key ?') // set data to local data

data.push('coucou'); // set data to local stack
data.push('my');
data.push('Bread');

data.set('toto', 'tutu'); // set 'toto' key and 'tutu' value
data.set('tutu', ['toto']);
data.tutu.push('test'); // get tutu instance created before and push to local stack in tutu instance

data.set('parent', 'I am THE parent');
data.parent.set('child', 'Am I the child ?');
data.parent.concat(['pop me', 'and me too']);
data.parent.pop(1); // remove element from stack
data.parent.pop();

data.set('removeMe', 'data')
data.unset('removeMe'); // remove instance + data 

console.log(data.get()); // get local data

console.log(data.get('tutu')); // get tutu data (data.tutu to get tutu instance)
console.log(data.tutu.getStack());

console.log(data.get('parent'));
console.log(data.parent.get('child'));
console.log(data.parent.getStack());

console.log(data.get('removeMe'));

console.log(data.getStack()); // get stack list
console.log(data.getAll()); // get all data from instance

Functions

NameDescriptionAdditionnal
set(key: string, data: any) : currentAdd data in key from current instance and create key instance
unset(key: string) : currentRemove data in key from current instance and remove key instance
push(data: any) : currentPush data in stack from current instance
concat(data: any) : currentConcat data with local stack from current instance
pop(key: number) : currentRemove element from stack
get(key: string) : currentGet specific data from current instance
getStack() : currentGet all local stack from current instance
getAll() : currentGet all local data from current instance