csv-to-pouch
Advanced tools
Comparing version 2.0.1 to 2.0.2
122
index.js
@@ -6,3 +6,4 @@ 'use strict'; | ||
var parse = _interopDefault(require('csv-parse')); | ||
var stream = _interopDefault(require('stream')); | ||
var stream = require('stream'); | ||
var stream__default = _interopDefault(stream); | ||
var util = _interopDefault(require('util')); | ||
@@ -17,3 +18,3 @@ var batch = _interopDefault(require('stream-batch')); | ||
stream$1 = stream; | ||
stream$1 = stream__default; | ||
@@ -188,18 +189,2 @@ util$1 = util; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
var index$1 = createCommonjsModule(function (module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function wrapRead(readFunc) { | ||
return (size) => Promise.resolve(readFunc(size)) | ||
.then((result) => { if (result !== undefined) this.push(result); }) | ||
.catch(err => this.emit('error', err)); | ||
} | ||
function wrapWrite(writeFunc) { | ||
@@ -213,27 +198,3 @@ return (chunk, encoding, next) => | ||
} | ||
function wrapTransform(transformFunc) { | ||
return (chunk, encoding, next) => | ||
Promise.resolve(transformFunc(chunk, encoding)) | ||
.then((result) => next(null, result), next); | ||
} | ||
function wrapFlush(flushFunc) { | ||
return (next) => Promise.resolve(flushFunc()) | ||
.then((result) => { if (result !== undefined) this.push(result); }) | ||
.catch(next); | ||
} | ||
/** | ||
* Readable stream constructor that uses async functions for write rather | ||
* than callbacks. Create a stream as `new PromiseReadable(opts)`. | ||
*/ | ||
class PromiseReadable extends stream.Readable { | ||
constructor(options) { | ||
const superOpts = Object.assign({}, options); | ||
if (options.read) superOpts.read = wrapRead.call(this, options.read); | ||
super(superOpts); | ||
} | ||
} | ||
/** | ||
* Writable stream constructor that uses async functions for write rather | ||
@@ -253,46 +214,3 @@ * than callbacks. Create a stream as `new PromiseWritable(opts)`. | ||
/** | ||
* Duplex stream constructor that uses async functions for write rather | ||
* than callbacks. Create a stream as `new PromiseDuplex(opts)`. | ||
*/ | ||
class PromiseDuplex extends stream.Duplex { | ||
constructor(options) { | ||
const superOpts = Object.assign({}, options); | ||
if (options.read) superOpts.read = wrapRead.call(this, options.read); | ||
if (options.write) superOpts.write = wrapWrite(options.write); | ||
if (options.writev) superOpts.writev = wrapWritev(options.writev); | ||
super(superOpts); | ||
} | ||
} | ||
/** | ||
* Transform stream constructor that uses async functions for write rather | ||
* than callbacks. Create a stream as `new PromiseTransform(opts)`. | ||
*/ | ||
class PromiseTransform extends stream.Transform { | ||
constructor(options) { | ||
const superOpts = Object.assign({}, options); | ||
if (options.transform) superOpts.transform = wrapTransform(option.transform); | ||
if (options.flush) superOpts.flush = wrapFlush(option.flush); | ||
if (options.read) superOpts.read = wrapRead.call(this, options.read); | ||
if (options.write) superOpts.write = wrapWrite(options.write); | ||
if (options.writev) superOpts.writev = wrapWritev(options.writev); | ||
super(superOpts); | ||
} | ||
} | ||
/** | ||
* Returns a promise that resolves when a stream closes | ||
* @param {stream.Readable} stream | ||
* @returns {Promise} | ||
*/ | ||
function ended(stream$$1) { | ||
return new Promise((resolve, reject) => { | ||
stream$$1.once('end', resolve).once('error', reject); | ||
}); | ||
} | ||
/** | ||
* Returns a promise that resolves when a stream closes | ||
* @param {stream.Writable} stream | ||
@@ -308,32 +226,2 @@ * @returns {Promise} | ||
/** | ||
* Loads an entire stream's contents into a buffer in memory | ||
* @param {stream.Readable} stream | ||
* @returns {Promise<Buffer>} | ||
*/ | ||
function toBuffer(stream$$1) { | ||
const chunks = []; | ||
const output = new PromiseWritable({ | ||
decodeStrings: true, | ||
write(chunk) { chunks.push(chunk); }, | ||
}); | ||
return finished(stream$$1.pipe(output)) | ||
.then(() => Buffer.concat(chunks)); | ||
} | ||
exports.toBuffer = toBuffer; | ||
exports.PromiseReadable = PromiseReadable; | ||
exports.PromiseWritable = PromiseWritable; | ||
exports.PromiseDuplex = PromiseDuplex; | ||
exports.PromiseTransform = PromiseTransform; | ||
exports.ended = ended; | ||
exports.finished = finished; | ||
}); | ||
var index_3 = index$1.PromiseWritable; | ||
var index_7 = index$1.finished; | ||
/** | ||
* Creates a Writable stream that saves data into a PouchDB database. | ||
@@ -345,3 +233,3 @@ * @param {PouchDB} db | ||
function createPouchStream(db, pouchOpts) { | ||
return new index_3({ | ||
return new PromiseWritable({ | ||
objectMode: true, | ||
@@ -400,3 +288,3 @@ decodeStrings: false, | ||
await index_7(parsingStream); | ||
await finished(parsingStream); | ||
} | ||
@@ -403,0 +291,0 @@ |
{ | ||
"name": "csv-to-pouch", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"main": "index.js", | ||
"module": "index.mjs", | ||
"module": "index.es.js", | ||
"bin": { | ||
@@ -15,3 +15,3 @@ "csv-to-pouch": "./cmd.js" | ||
"devDependencies": { | ||
"promise-stream-utils": "^1.0.0", | ||
"promise-stream-utils": "^1.0.7", | ||
"rollup": "^0.41.5", | ||
@@ -29,4 +29,4 @@ "rollup-plugin-commonjs": "^8.0.2", | ||
"index.js.map", | ||
"index.mjs", | ||
"index.mjs.map", | ||
"index.es.js", | ||
"index.es.js.map", | ||
"index.d.ts", | ||
@@ -33,0 +33,0 @@ "cmd.js" |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
55354
601
2