Initial commit

This commit is contained in:
Spencer Pincott
2024-07-15 22:20:13 -04:00
commit 97737ca1ae
16618 changed files with 934131 additions and 0 deletions

4
themes/keepit/node_modules/stream-transform/.babelrc generated vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env"],
"sourceRoot": "./lib"
}

View File

@@ -0,0 +1,53 @@
# Changelog
## Version 1.0.8
Project Management
* package: update license to MIT
* travis: test agains Node.js 11
## Version 1.0.7
* readme: fix website urls
## Version 1.0.6
* readme: fix links to project website
## Version 1.0.5
* package: move to csv.js.org
* package: upgrade dependencies including babel 7
* example: new sequential mode sample
* examples: new state examples
* examples: new api sync example
* examples: new mixed output stream example
* handler: bind execution context with current instance
## Version 1.0.4
* readme: update travis badge
## Version 1.0.3
* travis: support Node.js 10
* package: improve ignore files
* samples: update syntax
* sync: new module to ease synchronous usage
* stream: dont push empty string
## Version 1.0.2
* package: move babel to dev dependencies
## Version 1.0.1
* package: es5 backward compatibility
* package: ignore yarn lock file
## v0.2.0
* test: should require handled by mocha
* package: coffeescript 2 and use semver tilde

21
themes/keepit/node_modules/stream-transform/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2010 Adaltas
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

49
themes/keepit/node_modules/stream-transform/README.md generated vendored Normal file
View File

@@ -0,0 +1,49 @@
[![Build Status](https://api.travis-ci.org/adaltas/node-stream-transform.svg)](https://travis-ci.org/#!/adaltas/node-stream-transform)
Part of the [CSV module](https://csv.js.org/), this project is a simple object transformation framework. It implements the Node.js [`stream.Transform` API](http://nodejs.org/api/stream.html#stream_class_stream_transform). It also provides a simple callback-based API for convenience. It is both extremely easy to use and powerful.
## Documentation
* [Project homepage](http://csv.js.org/transform/)
* [API](http://csv.js.org/transform/api/)
* [Options](http://csv.js.org/transform/options/)
* [Handler](http://csv.js.org/transform/handler/)
* [State properties](http://csv.js.org/transform/state/)
* [Examples](http://csv.js.org/transform/examples/)
## Features
* Extends the native Node.js [transform stream API](http://nodejs.org/api/stream.html#stream_class_stream_transform)
* Simplicity with the optional callback and sync API
* Pipe transformations between readable and writable streams
* Synchronous versus asynchronous user functions
* Sequential and parallel execution
* Accept object, array or JSON as input and output
* Sequential or user-defined concurrent execution
* Skip and multiply records
* Alter or clone input records
* MIT License
## Usage
The module is built on the Node.js Stream API. For the sake of simplify, a simple callback API is also provided. To give you a quick look, here's an example of the callback API:
```javascript
var transform = require('stream-transform');
input = [ [ '1', '2', '3', '4' ], [ 'a', 'b', 'c', 'd' ] ];
transform(input, function(data){
data.push(data.shift());
return data.join(',')+'\n';
}, function(err, output){
output.should.eql([ '2,3,4,1\n', 'b,c,d,a\n' ]);
});
```
## Development
Tests are executed with mocha. To install it, simple run `npm install` followed by `npm test`. It will install mocha and its dependencies in your project "node_modules" directory and run the test suite. The tests run against the CoffeeScript source files.
To generate the JavaScript files, run `npm run coffee`.
The test suite is run online with [Travis](http://travis-ci.org/wdavidw/node-stream-transform). See the [Travis definition file](https://github.com/adaltas/node-stream-transform/blob/master/.travis.yml) to view the tested Node.js version.

View File

@@ -0,0 +1,228 @@
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
// Generated by CoffeeScript 2.3.2
// # Stream Transformer
// Pass all elements of an array or a stream to transform, filter and add. Features include:
// * Extends the Node.js "stream.Transform" API.
// * Both synchrounous and asynchronous support based and user callback
// arguments signature.
// * Ability to skip data.
// * Sequential and concurrent execution using the "parallel" options.
// Please look at the [README], the [samples] and the [tests] for additional
// information.
var Transformer, stream, util;
stream = require('stream');
util = require('util'); // ## Usage
// Callback approach, for ease of use:
// `transform([data], handler, [options])`
// Stream API, for maximum of power:
// `transform([data], [options], handler, [options], [callback])`
module.exports = function () {
var argument, callback, data, error, handler, i, j, k, len, options, result, transform, type, v;
options = {};
for (i = j = 0, len = arguments.length; j < len; i = ++j) {
argument = arguments[i];
type = _typeof(argument);
if (argument === null) {
type = 'null';
} else if (type === 'object' && Array.isArray(argument)) {
type = 'array';
}
if (i === 0) {
if (type === 'function') {
handler = argument;
} else if (type !== null) {
data = argument;
}
continue;
}
if (type === 'object') {
for (k in argument) {
v = argument[k];
options[k] = v;
}
} else if (type === 'function') {
if (handler && i === arguments.length - 1) {
callback = argument;
} else {
handler = argument;
}
} else if (type !== 'null') {
throw new Error('Invalid arguments');
}
}
transform = new Transformer(options, handler);
error = false;
if (data) {
process.nextTick(function () {
var len1, m, row;
for (m = 0, len1 = data.length; m < len1; m++) {
row = data[m];
if (error) {
break;
}
transform.write(row);
}
return transform.end();
});
}
if (callback || options.consume) {
result = [];
transform.on('readable', function () {
var record, results;
results = [];
while (record = transform.read()) {
if (callback) {
results.push(result.push(record));
} else {
results.push(void 0);
}
}
return results;
});
transform.on('error', function (err) {
error = true;
if (callback) {
return callback(err);
}
});
transform.on('end', function () {
if (callback && !error) {
return callback(null, result);
}
});
}
return transform;
}; // ## Transformer
// Options are documented [here](http://csv.js.org/transform/options/).
Transformer = function Transformer() {
var options1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var transform1 = arguments.length > 1 ? arguments[1] : undefined;
var base;
this.options = options1;
this.transform = transform1;
this.options.objectMode = true;
if ((base = this.options).parallel == null) {
base.parallel = 100;
}
stream.Transform.call(this, this.options);
this.running = 0;
this.started = 0;
this.finished = 0;
return this;
};
util.inherits(Transformer, stream.Transform);
module.exports.Transformer = Transformer;
Transformer.prototype._transform = function (chunk, encoding, cb) {
var _this = this;
var callback, err, l;
this.started++;
this.running++;
if (this.running < this.options.parallel) {
cb();
cb = null;
}
try {
l = this.transform.length;
if (this.options.params != null) {
l--;
}
if (l === 1) {
// sync
this.__done(null, [this.transform.call(this, chunk, this.options.params)], cb);
} else if (l === 2) {
// async
callback = function callback(err) {
for (var _len = arguments.length, chunks = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
chunks[_key - 1] = arguments[_key];
}
return _this.__done(err, chunks, cb);
};
this.transform.call(this, chunk, callback, this.options.params);
} else {
throw Error("Invalid handler arguments");
}
return false;
} catch (error1) {
err = error1;
return this.__done(err);
}
};
Transformer.prototype._flush = function (cb) {
this._ending = function () {
if (this.running === 0) {
return cb();
}
};
return this._ending();
};
Transformer.prototype.__done = function (err, chunks, cb) {
var chunk, j, len;
this.running--;
if (err) {
return this.emit('error', err);
}
this.finished++;
for (j = 0, len = chunks.length; j < len; j++) {
chunk = chunks[j];
if (typeof chunk === 'number') {
chunk = "".concat(chunk);
}
if (chunk != null && chunk !== '') {
// We dont push empty string
// See https://nodejs.org/api/stream.html#stream_readable_push
this.push(chunk);
}
}
if (cb) {
cb();
}
if (this._ending) {
return this._ending();
}
}; // [readme]: https://github.com/wdavidw/node-stream-transform
// [samples]: https://github.com/wdavidw/node-stream-transform/tree/master/samples
// [tests]: https://github.com/wdavidw/node-stream-transform/tree/master/test

View File

@@ -0,0 +1,81 @@
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
// Generated by CoffeeScript 2.3.2
// # Stream Transformer Sync
// Provides a synchronous alternative to the CSV transformer.
// ## Usage
// `const records = transform(data, [options])`
// ## Source Code
var transform;
transform = require('.');
module.exports = function () {
var argument, callback, chunks, data, expected_handler_length, handler, i, j, k, l, len, len1, options, record, transformer, type, v; // Import arguments normalization
options = {};
for (i = j = 0, len = arguments.length; j < len; i = ++j) {
argument = arguments[i];
type = _typeof(argument);
if (argument === null) {
type = 'null';
} else if (type === 'object' && Array.isArray(argument)) {
type = 'array';
}
if (i === 0) {
if (type === 'function') {
handler = argument;
} else if (type !== null) {
data = argument;
}
continue;
}
if (type === 'object') {
for (k in argument) {
v = argument[k];
options[k] = v;
}
} else if (type === 'function') {
if (handler && i === arguments.length - 1) {
callback = argument;
} else {
handler = argument;
}
} else if (type !== 'null') {
throw new Error('Invalid arguments');
}
} // Validate arguments
expected_handler_length = 1;
if (options.params) {
expected_handler_length++;
}
if (handler.length > expected_handler_length) {
throw Error('Invalid Handler: only synchonous handlers are supported');
} // Start transformation
chunks = [];
transformer = new transform.Transformer(options, handler);
transformer.push = function (chunk) {
return chunks.push(chunk);
};
for (l = 0, len1 = data.length; l < len1; l++) {
record = data[l];
transformer._transform(record, null, function () {});
}
return chunks;
};

View File

@@ -0,0 +1,196 @@
// Generated by CoffeeScript 2.3.2
// # Stream Transformer
// Pass all elements of an array or a stream to transform, filter and add. Features include:
// * Extends the Node.js "stream.Transform" API.
// * Both synchrounous and asynchronous support based and user callback
// arguments signature.
// * Ability to skip data.
// * Sequential and concurrent execution using the "parallel" options.
// Please look at the [README], the [samples] and the [tests] for additional
// information.
var Transformer, stream, util;
stream = require('stream');
util = require('util');
// ## Usage
// Callback approach, for ease of use:
// `transform([data], handler, [options])`
// Stream API, for maximum of power:
// `transform([data], [options], handler, [options], [callback])`
module.exports = function() {
var argument, callback, data, error, handler, i, j, k, len, options, result, transform, type, v;
options = {};
for (i = j = 0, len = arguments.length; j < len; i = ++j) {
argument = arguments[i];
type = typeof argument;
if (argument === null) {
type = 'null';
} else if (type === 'object' && Array.isArray(argument)) {
type = 'array';
}
if (i === 0) {
if (type === 'function') {
handler = argument;
} else if (type !== null) {
data = argument;
}
continue;
}
if (type === 'object') {
for (k in argument) {
v = argument[k];
options[k] = v;
}
} else if (type === 'function') {
if (handler && i === arguments.length - 1) {
callback = argument;
} else {
handler = argument;
}
} else if (type !== 'null') {
throw new Error('Invalid arguments');
}
}
transform = new Transformer(options, handler);
error = false;
if (data) {
process.nextTick(function() {
var len1, m, row;
for (m = 0, len1 = data.length; m < len1; m++) {
row = data[m];
if (error) {
break;
}
transform.write(row);
}
return transform.end();
});
}
if (callback || options.consume) {
result = [];
transform.on('readable', function() {
var record, results;
results = [];
while ((record = transform.read())) {
if (callback) {
results.push(result.push(record));
} else {
results.push(void 0);
}
}
return results;
});
transform.on('error', function(err) {
error = true;
if (callback) {
return callback(err);
}
});
transform.on('end', function() {
if (callback && !error) {
return callback(null, result);
}
});
}
return transform;
};
// ## Transformer
// Options are documented [here](http://csv.js.org/transform/options/).
Transformer = function(options1 = {}, transform1) {
var base;
this.options = options1;
this.transform = transform1;
this.options.objectMode = true;
if ((base = this.options).parallel == null) {
base.parallel = 100;
}
stream.Transform.call(this, this.options);
this.running = 0;
this.started = 0;
this.finished = 0;
return this;
};
util.inherits(Transformer, stream.Transform);
module.exports.Transformer = Transformer;
Transformer.prototype._transform = function(chunk, encoding, cb) {
var callback, err, l;
this.started++;
this.running++;
if (this.running < this.options.parallel) {
cb();
cb = null;
}
try {
l = this.transform.length;
if (this.options.params != null) {
l--;
}
if (l === 1) { // sync
this.__done(null, [this.transform.call(this, chunk, this.options.params)], cb);
} else if (l === 2) { // async
callback = (err, ...chunks) => {
return this.__done(err, chunks, cb);
};
this.transform.call(this, chunk, callback, this.options.params);
} else {
throw Error("Invalid handler arguments");
}
return false;
} catch (error1) {
err = error1;
return this.__done(err);
}
};
Transformer.prototype._flush = function(cb) {
this._ending = function() {
if (this.running === 0) {
return cb();
}
};
return this._ending();
};
Transformer.prototype.__done = function(err, chunks, cb) {
var chunk, j, len;
this.running--;
if (err) {
return this.emit('error', err);
}
this.finished++;
for (j = 0, len = chunks.length; j < len; j++) {
chunk = chunks[j];
if (typeof chunk === 'number') {
chunk = `${chunk}`;
}
if ((chunk != null) && chunk !== '') {
// We dont push empty string
// See https://nodejs.org/api/stream.html#stream_readable_push
this.push(chunk);
}
}
if (cb) {
cb();
}
if (this._ending) {
return this._ending();
}
};
// [readme]: https://github.com/wdavidw/node-stream-transform
// [samples]: https://github.com/wdavidw/node-stream-transform/tree/master/samples
// [tests]: https://github.com/wdavidw/node-stream-transform/tree/master/test

View File

@@ -0,0 +1,69 @@
// Generated by CoffeeScript 2.3.2
// # Stream Transformer Sync
// Provides a synchronous alternative to the CSV transformer.
// ## Usage
// `const records = transform(data, [options])`
// ## Source Code
var transform;
transform = require('.');
module.exports = function() {
var argument, callback, chunks, data, expected_handler_length, handler, i, j, k, l, len, len1, options, record, transformer, type, v;
// Import arguments normalization
options = {};
for (i = j = 0, len = arguments.length; j < len; i = ++j) {
argument = arguments[i];
type = typeof argument;
if (argument === null) {
type = 'null';
} else if (type === 'object' && Array.isArray(argument)) {
type = 'array';
}
if (i === 0) {
if (type === 'function') {
handler = argument;
} else if (type !== null) {
data = argument;
}
continue;
}
if (type === 'object') {
for (k in argument) {
v = argument[k];
options[k] = v;
}
} else if (type === 'function') {
if (handler && i === arguments.length - 1) {
callback = argument;
} else {
handler = argument;
}
} else if (type !== 'null') {
throw new Error('Invalid arguments');
}
}
// Validate arguments
expected_handler_length = 1;
if (options.params) {
expected_handler_length++;
}
if (handler.length > expected_handler_length) {
throw Error('Invalid Handler: only synchonous handlers are supported');
}
// Start transformation
chunks = [];
transformer = new transform.Transformer(options, handler);
transformer.push = function(chunk) {
return chunks.push(chunk);
};
for (l = 0, len1 = data.length; l < len1; l++) {
record = data[l];
transformer._transform(record, null, (function() {}));
}
return chunks;
};

View File

@@ -0,0 +1,40 @@
{
"version": "1.0.8",
"name": "stream-transform",
"description": "Object transformations implementing the Node.js `stream.Transform` API",
"keywords": [
"stream",
"transform",
"csv",
"object"
],
"license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "http://www.github.com/adaltas/node-stream-transform"
},
"homepage": "https://csv.js.org/transform/",
"devDependencies": {
"@babel/cli": "^7.1.0",
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"coffeescript": "~2.3.2",
"csv-generate": "~2.1.0",
"mocha": "~5.2.0",
"pad": "~2.2.1",
"should": "~13.2.3"
},
"optionalDependencies": {},
"main": "./lib",
"scripts": {
"preversion": "rm -rf lib && npm test && grep '## Trunk' CHANGELOG.md",
"version": "version=`grep '^ \"version\": ' package.json | sed 's/.*\"\\([0-9\\.]*\\)\".*/\\1/'` && sed -i \"s/## Trunk/## Version $version/\" CHANGELOG.md && git add CHANGELOG.md",
"postversion": "git push && git push --tags && npm publish",
"patch": "npm version patch -m 'Bump to version %s'",
"minor": "npm version minor -m 'Bump to version %s'",
"major": "npm version major -m 'Bump to version %s'",
"coffee": "coffee -b -o lib src && cd lib && babel *.js -d es5 && cd ..",
"pretest": "coffee -b -o lib src && cd lib && babel *.js -d es5 && cd ..",
"test": "mocha test/**/*.coffee"
}
}

View File

@@ -0,0 +1,16 @@
const transform = require('..')
const assert = require('assert')
transform([
['1','2','3','4'],
['a','b','c','d']
], function(data){
data.push(data.shift())
return data
}, function(err, output){
assert.deepEqual(output, [
[ '2', '3', '4', '1' ],
[ 'b', 'c', 'd', 'a' ]
])
})

View File

@@ -0,0 +1,26 @@
const transform = require('..')
const assert = require('assert')
const output = []
const transformer = transform(function(data){
data.push(data.shift())
return data
})
transformer.on('readable', function(){
while(row = transformer.read()){
output.push(row)
}
})
transformer.on('error', function(err){
console.log(err.message)
})
transformer.on('finish', function(){
assert.deepEqual(output, [
[ '2', '3', '4', '1' ],
[ 'b', 'c', 'd', 'a' ]
])
})
transformer.write(['1','2','3','4'])
transformer.write(['a','b','c','d'])
transformer.end()

View File

@@ -0,0 +1,15 @@
const transform = require('../lib/sync')
const assert = require('assert')
const data = transform([
[ 'a', 'b', 'c', 'd' ],
[ '1', '2', '3', '4' ]
], function(data){
data.push(data.shift())
return data
})
assert.deepEqual(data, [
[ 'b', 'c', 'd', 'a' ],
[ '2', '3', '4', '1' ]
])

View File

@@ -0,0 +1,26 @@
const transform = require('..')
const assert = require('assert')
const output = []
transform([
['1','2','3','4'],
['a','b','c','d']
], function(data){
data.push(data.shift())
return data
})
.on('readable', function(){
while(row = this.read()){
output.push(row)
}
})
.on('error', function(err){
console.log(err.message)
})
.on('finish', function(){
assert.deepEqual(output, [
[ '2', '3', '4', '1' ],
[ 'b', 'c', 'd', 'a' ]
])
})

View File

@@ -0,0 +1,20 @@
const transform = require('..')
const assert = require('assert')
// Generate a dataset of 500 records
const records = '.'.repeat(500).split('.').map( (_, i) => i )
// Transform the dataset
transform(records, {
parallel: 1
}, function(record, callback){
setTimeout(function(){
callback(null, record)
// Random timeout to prove sequential execution
}, Math.ceil(Math.random() * 10))
}, function(err, records){
assert.equal(
records.join(','),
'.'.repeat(500).split('.').map( (_, i) => i ).join(',')
)
})

View File

@@ -0,0 +1,19 @@
const transform = require('..')
transform([
['1','2','3','4'],
['a','b','c','d']
], function(data, callback){
setImmediate(function(){
data.push(data.shift())
callback(null, data.join(',')+'\n')
})
}, {
parallel: 20
})
.pipe(process.stdout)
// Output:
// 2,3,4,1
// b,c,d,a

View File

@@ -0,0 +1,15 @@
const transform = require('..')
transform([
['1','2','3','4'],
['a','b','c','d']
], function(data){
data.push(data.shift())
return data.join(',')+'\n'
})
.pipe(process.stdout)
// Output:
// 2,3,4,1
// b,c,d,a

View File

@@ -0,0 +1,26 @@
const transform = require('..')
const assert = require('assert')
// Generate a dataset of 5 records
const records = 'record\n'.repeat(5).trim().split('\n')
let test_running = records.length
let test_started = records.length
let test_finished = 0
// Execute the transformation
transform(records, function(record, callback){
setTimeout( () => {
const {running, started, finished} = this
assert.equal(running, test_running--)
assert.equal(started, test_started)
assert.equal(finished, test_finished++)
callback(null, `${running}_${started}_${finished}\n`)
}, 100)
})
// Get notify on error
.on('end', function(){
process.stdout.write('-------\n')
const {running, started, finished} = this
process.stdout.write(`${running}_${started}_${finished}\n`)
})
// Print the transformed records to the standard output
.pipe(process.stdout)

View File

@@ -0,0 +1,19 @@
const transform = require('..')
// Generate a dataset of 5 records
const records = 'record\n'.repeat(5).trim().split('\n')
// Initialize the transformation
const transformer = transform(records, (record, callback) => {
setTimeout( () => {
const {running, started, finished} = transformer
callback(null, `${running}_${started}_${finished}\n`)
}, 100)
})
// Get notify when done
transformer.on('end', () => {
process.stdout.write('-------\n')
const {running, started, finished} = transformer
process.stdout.write(`${running}_${started}_${finished}\n`)
})
// Print the transformed records to the standard output
transformer.pipe(process.stdout)