{"id":15607903,"url":"https://github.com/pomco/assembly-mill","last_synced_at":"2026-05-11T06:02:07.343Z","repository":{"id":57194047,"uuid":"83886138","full_name":"pomco/assembly-mill","owner":"pomco","description":"Assemble  data according to the designated file which as a template.","archived":false,"fork":false,"pushed_at":"2017-03-05T10:42:25.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-06T21:48:12.993Z","etag":null,"topics":["javascript","json","nodejs","nodejs-modules"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pomco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-04T10:40:22.000Z","updated_at":"2017-03-11T17:56:08.000Z","dependencies_parsed_at":"2022-09-15T22:31:17.636Z","dependency_job_id":null,"html_url":"https://github.com/pomco/assembly-mill","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomco%2Fassembly-mill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomco%2Fassembly-mill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomco%2Fassembly-mill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomco%2Fassembly-mill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pomco","download_url":"https://codeload.github.com/pomco/assembly-mill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246193334,"owners_count":20738472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","json","nodejs","nodejs-modules"],"created_at":"2024-10-03T05:05:05.008Z","updated_at":"2026-05-11T06:02:02.310Z","avatar_url":"https://github.com/pomco.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asseambly-mill\n*Assemble  data according to the designated  template file.*\n\n[![Build Status](https://travis-ci.org/pomco/assembly-mill.svg)](https://travis-ci.org/pomco/assembly-mill)\n[![Coverage Status](https://coveralls.io/repos/github/pomco/assembly-mill/badge.svg)](https://coveralls.io/repos/github/pomco/assembly-mill)\n[![Dependencies Status](https://david-dm.org/pomco/assembly-mill.svg)](https://david-dm.org/pomco/assembly-mill.svg)\n\n[![NPM](https://nodei.co/npm/assembly-mill.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/assembly-mill/)\n\n##supported format:\n- json\n\n---------------------\n\n## example\n\u003e - file structure\n``` schema     \n         └──  home\n               └── pomco\n\t\t\t\t├──  example.js\n\t\t\t\t└──  demo.json\t\n```\n \u003e - demo.json \n*the designated file*\n```js\n{\n      \"zoo\"  :  \"\",\n      \"canteen \" : [\n\t\t{\n\t\t\t\"name\" : \"star wark\",\n\t\t\t\"capacity\" : 30,\n\t\t\t\"food\" : []\n\t\t },\n\t\t{\n\t\t\t\"name\" : \"\",\n\t\t\t\"capacity\":0,\n\t\t\t\"food\":[]\n\t\t}\n\t],\n\tother : {\n\t}                                     \n}                                                                \n```\n \u003e - example.js :\n```js\nvar assembly = require('assembly-mill');\nvar obj = {\n\t\"zoo\" : \"The South Zoo\",\n\t\"canteen\" :[\n\t\t{\"name\" : \"miss you\"}\n\t]\n};\nvar tm = assembly.regist('demo.json');\n///**\n//* in fact ,there some ways to passing the arg.\u003c/br\u003e\n//* its is up to you to choose whice way to passing the file.\u003c/br\u003e\n//* as show below :\u003c/br\u003e\n//*\n//* var tmp = assembly.regist('demo.json');\n//* or\n//* var tmp = assembly.regist('/home/pomco/demo.json');\n//* and so on\n//*/\t\ntm.fill(obj);\nconsole.log(tm.render());\n```\n \u003e - expected\n*fillin  data accord to the file --\u003e\u003e \"demo.json\"*\n```js\n// `node example.js ` , then show as below:\n{\n      \"zoo\"  :  \"The South Zoo\",\n      \"canteen \" : [\n\t\t{\n\t\t\t\"name\" : \"miss you\",\n\t\t\t\"capacity\" : 30,\n\t\t\t\"food\" : []\n\t\t },\n\t\t{\n\t\t\t\"name\" : \"\",\n\t\t\t\"capacity\":0,\n\t\t\t\"food\":[]\n\t\t}\n\t],\n\tother : {\n\t}                                     \n}  \n```\n\n------------\n## install\n```sh \nnpm install  assembly-mill \n```\n\n## usage\n```js\nvar assembly = require('assembly-mill');\n```\n### assembly.regist(designatedfile)\n*regist the designated file  ,then return an object*\n#### @param  designatedfile\n - \u003e designatedfile \n```illustration\n the file to pass in \u003c/br\u003e\n// absolute path (or maybe the full path)  --\u003e \"/home/pomco/demo.json\"\n// relative path+filename  --\u003e \"./../demo.json\"  、\"./demo.json\"\n// filename  --\u003e\"demo.json\"\n```\n\n```js\nvar mill = assembly.regist(\"demo.json\");\n```\n### mill.fill(obj)\n*fillin data according the designated file , such as 'demo.json'*\n#### @param  obj\n - \u003e obj\n```illustration\nan object \n// contains keys and values, which maybe need to been modified \u003c/br\u003e\n// or added ,  maybe do nothing to change. \u003c/br\u003e\n// what  actually behavior to been showed is up on some rules.\u003c/br\u003e\n```\n\n### mill.render()\n*render the result , return an object.*\n\n\n## about devlopment\n- test the module\n*mocha ,chai*\n```sh\n\tnpm test \n```\n- test the systax or watch on some info in the backend\n*grunt-contrib-jshint ,grunt-contrib-watch*\n```sh\n \tgrunt\n```\n## more example \n- \u003e  example_01.js\n``` js\nvar assembly = require('assembly-mill');\nvar obj ={\n\t\"canteen \"[\n\t\t{\n\t\t\t\"capacity\" : 50,\n\t\t}\n\t\t{\n\t\t\t\"food\" : [\"chicken\",\"hotdog\"]\n\t\t}\n\t]\n};\nvar tm = assembly.regist('demo.json');\ntm.fill(obj);\nconsole.log(tm.render());\n```\n- \u003e expected\n\t- before\n\t```js\n{\n      \"zoo\"  :  \"\",\n      \"canteen \" : [\n\t\t{\n\t\t\t\"name\" : \"star wark\",\n\t\t\t\"capacity\" : 30,\n\t\t\t\"food\" : []\n\t\t },\n\t\t{\n\t\t\t\"name\" : \"\",\n\t\t\t\"capacity\":0,\n\t\t\t\"food\":[]\n\t\t}\n\t],\n\tother : {\n\t}                                     \n}   \n\t```\n\t- after\n```js\n{\n      \"zoo\"  :  \"\",\n      \"canteen \" : [\n\t\t{\n\t\t\t\"name\" : \"star wark\",\n\t\t\t\"capacity\" : 50,\n\t\t\t\"food\" : []\n\t\t },\n\t\t{\n\t\t\t\"name\" : \"\",\n\t\t\t\"capacity\":0,\n\t\t\t\"food\":[\"chicken\",\"hotdog\"]\n\t\t}\n\t],\n\tother : {\n\t}                                     \n} \n```  \n\n## read more\n### The  Rules\n**The rules** *that affect expectations*\n*as a matter of convenience , treated the designated file(such as 'demo.json')  as object named 'DemoObj' *\n- Rule one \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='string') \u0026\u0026 (typeof obj.key==='string') return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t DemoObj.key.lentgh\u003c=0 return true\n\t```\n\t\t- conditons-03:\n\t```dectiption\n\t Both JSON.pase(DemoObj.key)  \u0026\u0026  JSON.pase(obj.key)   return friendly\n\t```\n\t\t- conditons-04:\n\t```dectiption\n\tBoth JSON.pase(DemoObj.key)  \u0026\u0026  JSON.pase(obj.key)  throw sysntax error\n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true,then `DemoObj.key =obj.key`\nb) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively\nc) Bost  [conditons-01]  and [conditons-04] retun true,then `DemoObj.key =obj.key`\nd) others, nothing to change\n```\n- Rule two \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='string') \u0026\u0026 (typeof obj.key==='object'  but not instanof  'Array' ) return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t  JSON.pase(DemoObj.key)   return friendly\n\t```\n\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true,then go on recursively\nb) others, nothing to change\n```\n- Rule three \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='string') \u0026\u0026 (typeof obj.key==='object' and instanof Array) return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t DemoObj.key.lentgh\u003c=0 return true\n\t```\n\t\t- conditons-03:\n\t```dectiption\n\t Both JSON.pase(DemoObj.key)    return friendly\n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true,\n   when  (typeof  DemoObj.key === typeof obj.key[index]  \u0026\u0026 obj.key[index].length\u003e0) return true\n   then `DemoObj.key =Obj.key` \nb) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively\nc) others, nothing to change\n```\n- Rule four \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='object' but not instanof Array) \u0026\u0026 (typeof obj.key==='String') return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t  JSON.pase(obj.key)   return friendly\n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively\nb) others, nothing to change\n```\n\n- Rule five \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='object' but not instanof Array) \u0026\u0026 (typeof obj.key==='object' but not instanof Array) return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t JSON.stringfity( DemoObj.key.lentgh).length\u003c=2 return true\n\t```\n\t\t- conditons-03:\n\t```dectiption\n\t (typeof DemoObj.key==='number' ||  typeof DemoObj.key==='boolen' ) return true\n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true,then `DemoObj.key =obj.key`\nb) Bost  [conditons-01]  and [conditons-03] retrun true, then `DemoObj.key =obj.key`\nc) others, go on recursively\n```\n\n- Rule six \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='object' but not instanof Array) \u0026\u0026 (typeof obj.key==='object'  and instanof Array) return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\tJSON.stringfity( DemoObj.key.lentgh).length\u003c=2 return true\n\t```\n\t\t- conditons-03:\n\t```dectiption\n\t  (typeof DemoObj.key==='number' ||  typeof DemoObj.key==='boolen' ) return true\n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true,\n   when (typeof obj.key[index] ==='object' but not instanof Array \u0026\u0026 JSON.stringfity(obj.key[index]),length\u003e2) return true\nthen `DemoObj.key =Obj.key[index]`\nb) Bost  [conditons-01]  and [conditons-03] retrun true, then do nothing to change\nc) others, then go on recursively\n```\n\n- Rule seven \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='object'  and instanof Array) \u0026\u0026 (typeof obj.key==='string' ) return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t DemoObj.key.lentgh\u003c=0 return true\n\t```\n\t\t- conditons-03:\n\t```dectiption\n\tJSON.parse(obj.key) return true  \n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true, `DemoObj.key.push(obj.key)`\nb) Bost  [conditons-01]  and [conditons-03] retrun true, then go on recursively\nc) others, do nothing change\n```\n- Rule eight \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='object'  and instanof Array) \u0026\u0026 (typeof obj.key==='object' but not insanof Array) return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t DemoObj.key.lentgh\u003c=0 return true\n\t```\n\t\t- conditons-03:\n\t```dectiption\n\t   (typeof DemoObj.key[index]==='number' ||  typeof DemoObj.key[index]==='boolen' ) return true\n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true, `DemoObj.key.push(obj.key)`\nb) Bost  [conditons-01]  and [conditons-03] retrun true, then do nothing to change\nc) others, go on recursively\n```\n\n- Rule night \n\t- conditons\t \n\t\t- conditons-01:  \n\t```dectiption\n\t(typeof DemoObj.key ==='object'  and instanof Array) \u0026\u0026 (typeof obj.key==='object' and insanof Array) return true\n\t```\n\t\t- conditons-02:\n\t```dectiption\n\t DemoObj.key.lentgh\u003c=0 return true\n\t```\n\t\t- conditons-03:\n\t```dectiption\n\t   (typeof DemoObj.key[index]==='number' ||  typeof DemoObj.key[index]==='boolen' ) return true\n\t```\n\t- expected\n```expected\na) Bost  [conditons-01]  and [conditons-02]  retrun true, `DemoObj.key = obj.key`\nb) Bost  [conditons-01]  and [conditons-03] retrun true, `DemoObj.key = obj.key`\nc) others, go on recursively\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpomco%2Fassembly-mill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpomco%2Fassembly-mill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpomco%2Fassembly-mill/lists"}