Skip to content

adf0001/link-to-count-data-set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

link-to-count-data-set

a link-to count data set

Install

npm install link-to-count-data-set

Usage & Api

var link_to_count_data_set = require("link-to-count-data-set");

var log = [];

//.class( [fromDataCallback(fromData, item)] )
var ds = new link_to_count_data_set.class(
	function (fromData, item) { log.push(fromData, item.count); }
);

//add(from, to [, fromData] )
ds.add("a", "b", "a1");
ds.add("a", "c", "a1");
ds.add("a", "c", "a2");

//toItem: { from, count, to:{to->1}, fromData:{fromData->1} }
var expect = {
	"a": {
		from: "a",
		count: 2,
		to: { "b": 1, "c": 1 },
		fromData: { "a1": 1, "a2": 1 },
	}
};

done(!(
	JSON.stringify(ds.data) === JSON.stringify(expect) &&

	log.join(",") === "a1,1,a1,2,a2,2"
));

About

a link-to count data set

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published