npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

assembly-mill

v0.0.3

Published

Assemble data according to the designated template.

Downloads

5

Readme

asseambly-mill

Assemble data according to the designated template file.

Build Status Coverage Status Dependencies Status

NPM

##supported format:

  • json

example

  • file structure
         └──  home
               └── pomco
				├──  example.js
				└──  demo.json	
  • demo.json the designated file
{
      "zoo"  :  "",
      "canteen " : [
		{
			"name" : "star wark",
			"capacity" : 30,
			"food" : []
		 },
		{
			"name" : "",
			"capacity":0,
			"food":[]
		}
	],
	other : {
	}                                     
}                                                                
  • example.js :
var assembly = require('assembly-mill');
var obj = {
	"zoo" : "The South Zoo",
	"canteen" :[
		{"name" : "miss you"}
	]
};
var tm = assembly.regist('demo.json');
///**
//* in fact ,there some ways to passing the arg.</br>
//* its is up to you to choose whice way to passing the file.</br>
//* as show below :</br>
//*
//* var tmp = assembly.regist('demo.json');
//* or
//* var tmp = assembly.regist('/home/pomco/demo.json');
//* and so on
//*/	
tm.fill(obj);
console.log(tm.render());
  • expected fillin data accord to the file -->> "demo.json"
// `node example.js ` , then show as below:
{
      "zoo"  :  "The South Zoo",
      "canteen " : [
		{
			"name" : "miss you",
			"capacity" : 30,
			"food" : []
		 },
		{
			"name" : "",
			"capacity":0,
			"food":[]
		}
	],
	other : {
	}                                     
}  

install

npm install  assembly-mill 

usage

var assembly = require('assembly-mill');

assembly.regist(designatedfile)

regist the designated file ,then return an object

@param designatedfile

  • designatedfile

 the file to pass in </br>
// absolute path (or maybe the full path)  --> "/home/pomco/demo.json"
// relative path+filename  --> "./../demo.json"  、"./demo.json"
// filename  -->"demo.json"
var mill = assembly.regist("demo.json");

mill.fill(obj)

fillin data according the designated file , such as 'demo.json'

@param obj

  • obj

an object 
// contains keys and values, which maybe need to been modified </br>
// or added ,  maybe do nothing to change. </br>
// what  actually behavior to been showed is up on some rules.</br>

mill.render()

render the result , return an object.

about devlopment

  • test the module mocha ,chai
	npm test 
  • test the systax or watch on some info in the backend grunt-contrib-jshint ,grunt-contrib-watch
 	grunt

more example

  • example_01.js

var assembly = require('assembly-mill');
var obj ={
	"canteen "[
		{
			"capacity" : 50,
		}
		{
			"food" : ["chicken","hotdog"]
		}
	]
};
var tm = assembly.regist('demo.json');
tm.fill(obj);
console.log(tm.render());
  • expected

    • before

{ "zoo" : "", "canteen " : [ { "name" : "star wark", "capacity" : 30, "food" : [] }, { "name" : "", "capacity":0, "food":[] } ], other : { }
}
``` - after

{
      "zoo"  :  "",
      "canteen " : [
		{
			"name" : "star wark",
			"capacity" : 50,
			"food" : []
		 },
		{
			"name" : "",
			"capacity":0,
			"food":["chicken","hotdog"]
		}
	],
	other : {
	}                                     
} 

read more

The Rules

The rules that affect expectations *as a matter of convenience , treated the designated file(such as 'demo.json') as object named 'DemoObj' *

  • Rule one
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='string') && (typeof obj.key==='string') return true
      - conditons-02:
     DemoObj.key.lentgh<=0 return true
      - conditons-03:
     Both JSON.pase(DemoObj.key)  &&  JSON.pase(obj.key)   return friendly
      - conditons-04:
    Both JSON.pase(DemoObj.key)  &&  JSON.pase(obj.key)  throw sysntax error
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true,then `DemoObj.key =obj.key`
b) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively
c) Bost  [conditons-01]  and [conditons-04] retun true,then `DemoObj.key =obj.key`
d) others, nothing to change
  • Rule two

    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='string') && (typeof obj.key==='object'  but not instanof  'Array' ) return true
      - conditons-02:
      JSON.pase(DemoObj.key)   return friendly
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true,then go on recursively
b) others, nothing to change
  • Rule three
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='string') && (typeof obj.key==='object' and instanof Array) return true
      - conditons-02:
     DemoObj.key.lentgh<=0 return true
      - conditons-03:
     Both JSON.pase(DemoObj.key)    return friendly
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true,
   when  (typeof  DemoObj.key === typeof obj.key[index]  && obj.key[index].length>0) return true
   then `DemoObj.key =Obj.key` 
b) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively
c) others, nothing to change
  • Rule four
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='object' but not instanof Array) && (typeof obj.key==='String') return true
      - conditons-02:
      JSON.pase(obj.key)   return friendly
    • expected
a) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively
b) others, nothing to change
  • Rule five
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='object' but not instanof Array) && (typeof obj.key==='object' but not instanof Array) return true
      - conditons-02:
     JSON.stringfity( DemoObj.key.lentgh).length<=2 return true
      - conditons-03:
     (typeof DemoObj.key==='number' ||  typeof DemoObj.key==='boolen' ) return true
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true,then `DemoObj.key =obj.key`
b) Bost  [conditons-01]  and [conditons-03] retrun true, then `DemoObj.key =obj.key`
c) others, go on recursively
  • Rule six
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='object' but not instanof Array) && (typeof obj.key==='object'  and instanof Array) return true
      - conditons-02:
    JSON.stringfity( DemoObj.key.lentgh).length<=2 return true
      - conditons-03:
      (typeof DemoObj.key==='number' ||  typeof DemoObj.key==='boolen' ) return true
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true,
   when (typeof obj.key[index] ==='object' but not instanof Array && JSON.stringfity(obj.key[index]),length>2) return true
then `DemoObj.key =Obj.key[index]`
b) Bost  [conditons-01]  and [conditons-03] retrun true, then do nothing to change
c) others, then go on recursively
  • Rule seven
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='object'  and instanof Array) && (typeof obj.key==='string' ) return true
      - conditons-02:
     DemoObj.key.lentgh<=0 return true
      - conditons-03:
    JSON.parse(obj.key) return true  
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true, `DemoObj.key.push(obj.key)`
b) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively
c) others, do nothing change
  • Rule eight
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='object'  and instanof Array) && (typeof obj.key==='object' but not insanof Array) return true
      - conditons-02:
     DemoObj.key.lentgh<=0 return true
      - conditons-03:
       (typeof DemoObj.key[index]==='number' ||  typeof DemoObj.key[index]==='boolen' ) return true
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true, `DemoObj.key.push(obj.key)`
b) Bost  [conditons-01]  and [conditons-03] retrun true, then do nothing to change
c) others, go on recursively
  • Rule night
    • conditons
      • conditons-01:
    (typeof DemoObj.key ==='object'  and instanof Array) && (typeof obj.key==='object' and insanof Array) return true
      - conditons-02:
     DemoObj.key.lentgh<=0 return true
      - conditons-03:
       (typeof DemoObj.key[index]==='number' ||  typeof DemoObj.key[index]==='boolen' ) return true
    • expected
a) Bost  [conditons-01]  and [conditons-02]  retrun true, `DemoObj.key = obj.key`
b) Bost  [conditons-01]  and [conditons-03] retrun true, `DemoObj.key = obj.key`
c) others, go on recursively