Documents
Generator source code and files, with: text format, minification, indenting, and beautify.
This library also provides all the functions necessary to convert between different data types and store in files.
Installation
$> npm install gencode --save
Usage
Import
var gencode = ;//or;
Array to file
Storing an array in a file of any extension.
var array = '1' '2' '555543' '23423' 'Lorem ipsum' 'Lorem ipsum 2' 'Lorem ipsum 3' 231; gencode; /*Content of file /home/julian/Escritorio/test/array.txt =>1255554323423Lorem ipsumLorem ipsum 2Lorem ipsum 3231*/
Complex input
- name: file name, extension: html, txt, jade, jsx, css, xml, md, and many more.
- content:
- line: a line with any content (string, number, boolean) [Required]
- space: Initial spacing before the line (number) [Optional] Default 0 spaces
- tabs: Initial tabulations space. [Optional] Default 0 spaces, no tabs
Note:
- The main priority is the spaces, ie, if there are spaces and tabs then the_ spaces are taken.
var input = name: 'index.html' content: line: '<title>Example</title>' space: 0 tabs: 0 line: '<div class="header">' line: '<div class="container">' space: 4 tabs: 1 line: '<div class="logo">' space: 5 tabs: 1 line: '<a href="/">Title</a>' space: 5 tabs: 1 line: '</div>' space: 5 tabs: 1 line: '<div class="header-right">' space: 5 tabs: 1 line: '<a href="/empresa"><span>Hello</span></a>' space: 5 tabs: 1 line: '</div>' space: 2 tabs: 1 repeat: 2 tabs: 2 ;
Also
var input = name: 'index.html' content: line: '<title>Example</title>' space: 0 tabs: 0 line: '<div class="header">' line: '<div class="container">' tabs: 1 line: '<div class="logo">' space: 5 line: '<a href="/">Title</a>' space: 5 line: '</div>' space: 5 line: '<div class="header-right">' tabs: 1 line: '<a href="/empresa"><span>Hello</span></a>' space: 5 line: '</div>' space: 2 repeat: 2 //Repeats </div> two times ;
gencode
Output without file:
var input = name: 'index.html' content: line: '<title>Example</title>' space: 0 tabs: 0 line: '<div class="header">' line: '<div class="container">' space: 4 tabs: 1 line: '<div class="logo">' space: 5 tabs: 1 line: '<a href="/">Title</a>' space: 5 tabs: 1 line: '</div>' space: 5 tabs: 1 line: '<div class="header-right">' space: 5 tabs: 1 line: '<a href="/empresa"><span>Hello</span></a>' space: 5 tabs: 1 line: '</div>' space: 2 tabs: 1 repeat: 2 tabs: 2 //this is an error in strict mode. ; /** * [generator description] * @param {[json]} input [json input] * @param {[boolean]} false [strict mode, ends the generation if an error is found.] * @return {[string]} [output] */gencode;
Utils
Read file and process content
Content file ():
- a
- aaronita
- aarónico
- aba
- ababa
- ababillarse
- ababol
- abacal
gencodeutils; /*Result: ["a","aaronita","aarónico","aba","ababa","ababillarse","ababol","abacal"]*/
Save file
var content = "if (err) { reject(err); } else { resolve('successfull'); }"; gencode;
Generating separation
console;//Result:/* |Ends here the result */
console;//Result:// |Ends here the result
console;//Result://____|Ends here the result
var array = 'any' 'number' 'or' 'string' 100 200;gencodeutils;//Result://any//number//or//string//100//200
var array = 'any' 'number' 'or' 'string' 100 200;console; //\t, \n, _, etc.//any number or string 100 200