Skip to content

Commit

Permalink
add master files
Browse files Browse the repository at this point in the history
  • Loading branch information
billdong9 committed Oct 13, 2019
0 parents commit fe490c5
Show file tree
Hide file tree
Showing 416 changed files with 66,032 additions and 0 deletions.
Empty file added README.md
Empty file.
43 changes: 43 additions & 0 deletions index.browser.js
@@ -0,0 +1,43 @@
/**
* Power JSON
* @version 1.0.0-alpha
*
* @browserSupport
* Browsers:
* IE >= 11
* Edge All
* Firefox >= 6
* Chrome >= 21
* Safari >= 7.1
* Opera >= 15
*
* Nodejs:
* Nodejs >= 6
*
* @feature
* 1. comment support
* 2. {id: 1} instead of {"id": 1} (No quotes)
* 3. single quote support (support both '' and "")
* 4. multi-line string support
* 5. operator support, e.g. {id: 2 * (1 + 1)}
* 6. file support e.g. {file: new File('./myfile.txt')}
* 7. GET support e.g. {file: new GET('http://www.xxx.com')}
* 8. import support e.g. {anotherPJFile: new PJSON('./file2.pjson')}
*/

'use strict';

const parser = require('./parser/pjson.browser.js');

function parse(pjson) {
return parser.parse(pjson)
}

function stringify(pjson) {
return JSON.stringify(pjson);
}

window.PJSON = {
parse,
stringify
}
1 change: 1 addition & 0 deletions index.js

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions index.node.js
@@ -0,0 +1,78 @@
'use strict';

const path = require('path'),
fs = require('fs');

const parser = require('./parser/pjson.node.js');

function parse(pjson) {
return parser.parse(pjson, {
filepath: ''
})
}

function parseFile(filepath) {
if (path.extname(filepath) === '') {
filepath = filepath + '.pjson';
}

return new Promise(function(res, rej) {
const pjsonFile = fs.readFile(filepath, function(err, pjsonFile) {
if (err) {
rej();
return;
}
res(parser.parse(pjsonFile.toString(), {
filepath
}))
})
})
}

function parseFileSync(filepath) {
if (path.extname(filepath) === '') {
filepath = filepath + '.pjson';
}

const pjsonFile = fs.readFileSync(filepath).toString();
return parser.parse(pjsonFile, {
filepath
})
}

function stringify(pjson) {
return JSON.stringify(pjson);
}

function stringifyFile(filepath, pjson) {
if (path.extname(filepath) === '') {
filepath = filepath + '.pjson';
}

return new Promise(function(res, rej) {
fs.writeFile(filepath, JSON.stringify(pjson), function(err) {
if (err) {
rej();
return;
}
res();
})
})
}

function stringifyFileSync(filepath, pjson) {
if (path.extname(filepath) === '') {
filepath = filepath + '.pjson';
}

fs.writeFileSync(filepath, JSON.stringify(pjson));
}

module.exports = {
parse,
parseFile,
parseFileSync,
stringify,
stringifyFile,
stringifyFileSync
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/@types/concat-stream/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/@types/concat-stream/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions node_modules/@types/concat-stream/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions node_modules/@types/concat-stream/types-metadata.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions node_modules/@types/form-data/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions node_modules/@types/form-data/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions node_modules/@types/form-data/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions node_modules/@types/form-data/types-metadata.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/@types/node/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe490c5

Please sign in to comment.