+0
-0
@@ -0,0 +0,0 @@ language: node_js |
+7
-1
@@ -44,3 +44,9 @@ var internals = {}; | ||
| } | ||
| r[i.name] = symbol + parseFloat(v.splice(i.width - percision, 0, ".")).toFixed(percision); | ||
| if(lodash.includes(v, ".")){ | ||
| r[i.name] = symbol + parseFloat(v).toFixed(percision); | ||
| } | ||
| else{ | ||
| r[i.name] = symbol + parseFloat(v.splice(i.width - percision, 0, ".")).toFixed(percision); | ||
| } | ||
| break; | ||
@@ -47,0 +53,0 @@ case "int": |
+0
-0
@@ -0,0 +0,0 @@ The MIT License (MIT) |
+0
-0
| .PHONY: test | ||
| test: | ||
| mocha --check-leaks --reporter spec |
+1
-1
| { | ||
| "name": "fixy", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", | ||
| "description": "A Fixed Width Input Parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+1
-1
@@ -136,3 +136,3 @@ [](https://badge.fury.io/js/fixy) | ||
| - Float | ||
| - type : "float" | ||
| - type : "float" (decimal use allowed but not required) | ||
| - name (Required) | Name of the Column | ||
@@ -139,0 +139,0 @@ - width (Required) | Length of Column |
+119
-0
@@ -261,2 +261,121 @@ var fixy = require("../index"); | ||
| }); | ||
| it("should return fixed-width-input as array(object) if decimal within float", function(){ | ||
| var test = fixy.parse({ | ||
| map:[{ | ||
| name: "Age", | ||
| width: 2, | ||
| start: 1, | ||
| type: "int" | ||
| },{ | ||
| name: "Initial", | ||
| width: 3, | ||
| start: 3, | ||
| type: "string" | ||
| },{ | ||
| name: "DateEntered", | ||
| width: 8, | ||
| start: 6, | ||
| type: "date", | ||
| inputformat: "YYYYMMDD", | ||
| outputformat: "YYYY-MM-DD" | ||
| },{ | ||
| name: "IsBad", | ||
| width: 1, | ||
| start: 14, | ||
| type: "bool", | ||
| tVal: "Y", | ||
| fVal: "N" | ||
| },{ | ||
| name: "Rating", | ||
| width: 4, | ||
| start: 15, | ||
| type: "float", | ||
| percision: 2 | ||
| }], | ||
| options:{ | ||
| fullwidth: 18, | ||
| skiplines: null | ||
| } | ||
| }, "30SJP20121231N9.20"); | ||
| assert.deepEqual(test, [{ | ||
| Age: 30, | ||
| Initial: "SJP", | ||
| DateEntered: "2012-12-31", | ||
| IsBad: false, | ||
| Rating: 9.20 | ||
| }]); | ||
| }); | ||
| it("should return fixed-width-input (multi-leveled) as array(object) if decimal within float", function(){ | ||
| var test = fixy.parse({ | ||
| map:[{ | ||
| name: "Name", | ||
| width: 7, | ||
| start: 1, | ||
| type: "string", | ||
| level: "A" | ||
| },{ | ||
| name: "Age", | ||
| width: 2, | ||
| start: 1, | ||
| type: "int", | ||
| level: "B" | ||
| },{ | ||
| name: "Initial", | ||
| width: 3, | ||
| start: 3, | ||
| type: "string", | ||
| level: "B" | ||
| },{ | ||
| name: "DateEntered", | ||
| width: 8, | ||
| start: 6, | ||
| type: "date", | ||
| inputformat: "YYYYMMDD", | ||
| outputformat: "YYYY-MM-DD", | ||
| level: "B" | ||
| },{ | ||
| name: "IsBad", | ||
| width: 1, | ||
| start: 14, | ||
| type: "bool", | ||
| tVal: "Y", | ||
| fVal: "N", | ||
| level: "B" | ||
| },{ | ||
| name: "Rating", | ||
| width: 4, | ||
| start: 15, | ||
| type: "float", | ||
| percision: 2, | ||
| level: "B" | ||
| }], | ||
| options:{ | ||
| skiplines: null, | ||
| levels: { | ||
| "A": { | ||
| nickname: "A", | ||
| start: 0, | ||
| end: 0, | ||
| fullwidth: 7 | ||
| }, | ||
| "B": { | ||
| nickname: "B", | ||
| start: 1, | ||
| end: 2, | ||
| fullwidth: 18 | ||
| } | ||
| } | ||
| } | ||
| }, "Steve \n30SJP20121231N9.20"); | ||
| assert.deepEqual(test, { | ||
| A: [{ Name: "Steve" }], | ||
| B: [{ | ||
| Age: 30, | ||
| Initial: "SJP", | ||
| DateEntered: "2012-12-31", | ||
| IsBad: false, | ||
| Rating: 9.20 | ||
| }] | ||
| }); | ||
| }); | ||
| }); | ||
@@ -263,0 +382,0 @@ describe("#unparse()", 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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
25523
15.56%758
19.56%