code-stringify
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "code-stringify", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Code-this is node.js module that converts JavaScript variables into source codes. Unlike `JSON.stringify`, code-stringify also deals with reference(object) types of variables.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,2 @@ | ||
[](http://badge.fury.io/js/code-stringify) | ||
[](https://travis-ci.org/kaelzhang/node-code-stringify) | ||
[](https://gemnasium.com/kaelzhang/node-code-stringify) | ||
[](https://travis-ci.org/kaelzhang/node-code-stringify) | ||
@@ -32,5 +30,5 @@ # Code-this | ||
fs.writeFileSync( | ||
'output.js', | ||
'module.exports = ' + code(a, null, 2) | ||
); | ||
'output.js', | ||
'module.exports = ' + code(a, null, 2) | ||
) | ||
``` | ||
@@ -63,9 +61,8 @@ | ||
## Known Issues | ||
- Code-this can't deal with recursive objects or arrays SO FAR. | ||
- Can't deal with recursive objects or arrays SO FAR. | ||
- `space` parameter could not affect the code indent inside functions. | ||
- Code-this could not deal with variable scope so far. | ||
- Could not deal with variable scope so far. | ||
Those issues or tasks which should be done to enhance the module might be fixed in the future. Or there will be a million thanks if you fork and contribute ~~ | ||
Those issues or tasks which should be done to enhance the module might be fixed in the future. Or there will be a million thanks if you fork and contribute ~~ |
@@ -5,17 +5,39 @@ 'use strict'; | ||
var expect = require('chai').expect; | ||
var fs = require('fs') | ||
var node_path = require('path') | ||
var obj = { | ||
0: 1, | ||
2: 1, | ||
a: 1, | ||
b: '2', | ||
c: true, | ||
d: function(n){return n;}, | ||
e: [ {a: 1}, [1, '2'], '1' ], | ||
f: 1, | ||
g: 1, | ||
h: 1, | ||
i: 1 | ||
bc: '2', | ||
def: true, | ||
'g-h': function(n){return n;}, | ||
$i: [ | ||
{ | ||
a: 1 | ||
}, | ||
[ | ||
1, | ||
'2' | ||
], | ||
'1' | ||
], | ||
a0: 1, | ||
'0ab': 1 | ||
} | ||
var expected = fs.readFileSync( | ||
node_path.join(__dirname, 'expected') | ||
).toString() | ||
code.QUOTE = '\'' | ||
describe('complex', function () { | ||
it('all together', function () { | ||
var result = code(obj, null, 2) | ||
expect(result).to.equal(expected) | ||
}) | ||
}) | ||
describe("primitive types", function(){ | ||
@@ -22,0 +44,0 @@ it("number", function(){ |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10411
9
240
67
1