-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
47 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{ | ||
"name": "@nrd/fua.module.dfc", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Data Flow Control", | ||
"main": "src/module.dfc.js", | ||
"files": [ | ||
"src/*" | ||
], | ||
"dependencies": { | ||
"@nrd/fua.core.util": "^1.0.0" | ||
"@nrd/fua.core.assert": "^1.0.2", | ||
"@nrd/fua.core.is": "^1.0.7" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^8.2.1", | ||
|
@@ -27,4 +28,4 @@ | |
}, | ||
"author": "[email protected]", | ||
"license": "UNLICENSED" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const | ||
assert = require('@nrd/fua.core.assert'), | ||
is = require('@nrd/fua.core.is'), | ||
Transformer = require('./Transformer.js'); | ||
|
||
module.exports = function JSONTransformer(options = {}) { | ||
const transformer = Transformer(options.id || ''); | ||
|
||
transformer.use(function (source, output, next) { | ||
try { | ||
if (is.object(source)) source = JSON.stringify(source); | ||
assert(is.string(source), 'expected input to be a string'); | ||
output = JSON.parse(source); | ||
assert(is.object(output), 'expected output to be json'); | ||
next(null, output); | ||
} catch (err) { | ||
next(err); | ||
} | ||
}); | ||
|
||
return transformer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.Transformer = require('./Transformer.js'); | ||
exports.CSVTransformer = require('./CSVTransformer.js'); | ||
exports.JSONTransformer = require('./JSONTransformer.js'); | ||
|
||
Object.freeze(exports); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters