Comparing version 0.4.2 to 0.4.3
@@ -0,1 +1,2 @@ | ||
#!/usr/bin/env node | ||
export declare function main(): void; |
#!/usr/bin/env node | ||
"use strict"; | ||
var optimist = require('optimist'); | ||
var fs_1 = require('fs'); | ||
var async_1 = require('async'); | ||
var index_1 = require('../index'); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.main = void 0; | ||
var optimist = require("optimist"); | ||
var fs_1 = require("fs"); | ||
var async_1 = require("async"); | ||
var index_1 = require("../index"); | ||
function main() { | ||
@@ -106,9 +108,9 @@ var argvparser = optimist | ||
// process.stdin.setEncoding('utf8'); | ||
index_1.transform(process.stdin, parser_opts, stringifier_opts, exit); | ||
(0, index_1.transform)(process.stdin, parser_opts, stringifier_opts, exit); | ||
} | ||
else if (argv._.length) { | ||
var filepaths = argv._; | ||
async_1.eachSeries(filepaths, function (filepath, callback) { | ||
var stream = fs_1.createReadStream(filepath); | ||
index_1.transform(stream, parser_opts, stringifier_opts, callback); | ||
(0, async_1.eachSeries)(filepaths, function (filepath, callback) { | ||
var stream = (0, fs_1.createReadStream)(filepath); | ||
(0, index_1.transform)(stream, parser_opts, stringifier_opts, callback); | ||
console.error(''); // newline | ||
@@ -115,0 +117,0 @@ }, exit); |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
/** | ||
@@ -11,3 +12,3 @@ - `encoding` for converting to strings. | ||
/** character encoding */ | ||
encoding?: string; | ||
encoding?: BufferEncoding; | ||
/** string to represent missing data */ | ||
@@ -14,0 +15,0 @@ missing?: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.zip = exports.merge = void 0; | ||
/** | ||
@@ -3,0 +5,0 @@ Like reverse Object.assign, but with special treatment for undefined. |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { Parser, ParserConfiguration } from './parser'; | ||
@@ -2,0 +3,0 @@ import { Stringifier, StringifierConfiguration } from './stringifier'; |
14
index.js
"use strict"; | ||
var json_1 = require('streaming/json'); | ||
var property_1 = require('streaming/property'); | ||
var parser_1 = require('./parser'); | ||
exports.Parser = parser_1.Parser; | ||
var stringifier_1 = require('./stringifier'); | ||
exports.Stringifier = stringifier_1.Stringifier; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transform = exports.Stringifier = exports.Parser = void 0; | ||
var json_1 = require("streaming/json"); | ||
var property_1 = require("streaming/property"); | ||
var parser_1 = require("./parser"); | ||
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return parser_1.Parser; } }); | ||
var stringifier_1 = require("./stringifier"); | ||
Object.defineProperty(exports, "Stringifier", { enumerable: true, get: function () { return stringifier_1.Stringifier; } }); | ||
function transform(input, parserConfig, stringifierConfig, callback) { | ||
@@ -9,0 +11,0 @@ var transforms = [ |
{ | ||
"name": "sv", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Any separated values.", | ||
@@ -15,20 +15,19 @@ "keywords": [ | ||
"homepage": "https://github.com/chbrown/sv", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/chbrown/sv.git" | ||
}, | ||
"repository": "github:chbrown/sv", | ||
"author": "Christopher Brown <io@henrian.com> (http://henrian.com)", | ||
"license": "MIT", | ||
"dependencies": { | ||
"async": "*", | ||
"optimist": "*", | ||
"streaming": "*" | ||
"async": "^1.5.2", | ||
"optimist": "^0.6.1", | ||
"streaming": "^1.1.1" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "*", | ||
"declarations": "*", | ||
"istanbul": "*", | ||
"mocha": "*", | ||
"mocha-lcov-reporter": "*", | ||
"typescript": "*" | ||
"@types/mocha": "^2.2.43", | ||
"@types/node": "^18.11.9", | ||
"@types/optimist": "^0.0.33", | ||
"coveralls": "^3.1.1", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^2.4.5", | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"typescript": "^4.9.5" | ||
}, | ||
@@ -35,0 +34,0 @@ "scripts": { |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Transform } from 'stream'; | ||
@@ -28,3 +30,3 @@ import { Configuration } from './common'; | ||
_flush(callback: (error?: Error) => void): void; | ||
_transform(chunk: Buffer, encoding: string, callback: (error?: Error) => void): void; | ||
_transform(chunk: Buffer, encoding: BufferEncoding | 'buffer', callback: (error?: Error) => void): void; | ||
} |
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var stream_1 = require('stream'); | ||
var common_1 = require('./common'); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Parser = exports.inferDelimiter = exports.defaultParserConfiguration = void 0; | ||
var stream_1 = require("stream"); | ||
var common_1 = require("./common"); | ||
exports.defaultParserConfiguration = { | ||
@@ -35,3 +47,3 @@ encoding: 'utf8', | ||
44, | ||
32, | ||
32, // ' ' (space) | ||
]; | ||
@@ -51,26 +63,27 @@ // TODO: make this more robust (that's why I even counted them) | ||
*/ | ||
var Parser = (function (_super) { | ||
var Parser = /** @class */ (function (_super) { | ||
__extends(Parser, _super); | ||
function Parser(config) { | ||
if (config === void 0) { config = {}; } | ||
_super.call(this, { | ||
var _this = _super.call(this, { | ||
decodeStrings: true, | ||
readableObjectMode: true, | ||
writableObjectMode: false, | ||
}); | ||
this.byteBuffer = new Buffer(0); | ||
this.cellBuffer = []; | ||
}) || this; | ||
_this.byteBuffer = Buffer.alloc(0); | ||
_this.cellBuffer = []; | ||
// merge defaults | ||
this.config = common_1.merge(config, exports.defaultParserConfiguration); | ||
_this.config = (0, common_1.merge)(config, exports.defaultParserConfiguration); | ||
// special demarcating characters | ||
// 1. delimiter | ||
if (this.config.delimiter) { | ||
this.delimiterByte = this.config.delimiter.charCodeAt(0); | ||
if (_this.config.delimiter) { | ||
_this.delimiterByte = _this.config.delimiter.charCodeAt(0); | ||
} | ||
// 2. quote | ||
this.quoteByte = this.config.quotechar.charCodeAt(0); | ||
this.quotequoteRegExp = new RegExp(this.config.quotechar + this.config.quotechar, 'g'); | ||
_this.quoteByte = _this.config.quotechar.charCodeAt(0); | ||
_this.quotequoteRegExp = new RegExp(_this.config.quotechar + _this.config.quotechar, 'g'); | ||
// 3. escape | ||
this.escapeByte = this.config.escape.charCodeAt(0); | ||
this.escapeQuoteRegExp = new RegExp('\\' + this.config.escape + this.config.quotechar, 'g'); | ||
_this.escapeByte = _this.config.escape.charCodeAt(0); | ||
_this.escapeQuoteRegExp = new RegExp('\\' + _this.config.escape + _this.config.quotechar, 'g'); | ||
return _this; | ||
} | ||
@@ -83,3 +96,3 @@ Parser.prototype.writeRow = function (cells) { | ||
else { | ||
this.push(common_1.zip(this.config.columns, cells, this.config.missing)); | ||
this.push((0, common_1.zip)(this.config.columns, cells, this.config.missing)); | ||
} | ||
@@ -133,3 +146,5 @@ }; | ||
inside_quote = true; | ||
// we can only enter a quote at the edge of the cell (thus, i == start) | ||
} | ||
// otherwise we just wait for the delimiter | ||
else if ( | ||
@@ -136,0 +151,0 @@ // if we are at the very end of the input and this is the final chunk (ignoring any sort of state) |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Transform } from 'stream'; | ||
@@ -41,3 +43,3 @@ import { Configuration } from './common'; | ||
_flush(callback: (error?: Error) => void): void; | ||
_transform(chunk: any, encoding: string, callback: (error?: Error) => void): void; | ||
_transform(chunk: any, encoding: BufferEncoding, callback: (error?: Error) => void): void; | ||
} |
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var stream_1 = require('stream'); | ||
var common_1 = require('./common'); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Stringifier = exports.inferColumns = exports.defaultStringifierConfiguration = void 0; | ||
var stream_1 = require("stream"); | ||
var common_1 = require("./common"); | ||
exports.defaultStringifierConfiguration = { | ||
@@ -53,17 +65,18 @@ encoding: 'utf8', | ||
*/ | ||
var Stringifier = (function (_super) { | ||
var Stringifier = /** @class */ (function (_super) { | ||
__extends(Stringifier, _super); | ||
function Stringifier(config) { | ||
if (config === void 0) { config = {}; } | ||
_super.call(this, { readableObjectMode: false, writableObjectMode: true }); | ||
this.rowBuffer = []; | ||
this.config = common_1.merge(config, exports.defaultStringifierConfiguration); | ||
this.quotecharRegExp = new RegExp(this.config.quotechar, 'ig'); | ||
if (this.config.columns) { | ||
var _this = _super.call(this, { readableObjectMode: false, writableObjectMode: true }) || this; | ||
_this.rowBuffer = []; | ||
_this.config = (0, common_1.merge)(config, exports.defaultStringifierConfiguration); | ||
_this.quotecharRegExp = new RegExp(_this.config.quotechar, 'ig'); | ||
if (_this.config.columns) { | ||
// maybe we should write the columns even if we don't get any data? | ||
this.rowBuffer = [this.config.columns]; | ||
_this.rowBuffer = [_this.config.columns]; | ||
} | ||
else { | ||
this.rowBuffer = []; | ||
_this.rowBuffer = []; | ||
} | ||
return _this; | ||
} | ||
@@ -101,2 +114,4 @@ Stringifier.prototype.writeObject = function (object) { | ||
value = value.replace(this.quotecharRegExp, this.config.quotechar + this.config.quotechar); | ||
// serialize with escapes: | ||
// value = value.replace(this.quotechar_regex, '\\' + this.quotechar); | ||
} | ||
@@ -103,0 +118,0 @@ value = this.config.quotechar + value + this.config.quotechar; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
34562
742
0
8
13
2
+ Addedasync@1.5.2(transitive)
- Removedasync@3.2.6(transitive)
Updatedasync@^1.5.2
Updatedoptimist@^0.6.1
Updatedstreaming@^1.1.1