add lisp packages
This commit is contained in:
20
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/autoType.js
generated
vendored
Normal file
20
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/autoType.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export default function autoType(object) {
|
||||
for (var key in object) {
|
||||
var value = object[key].trim(), number, m;
|
||||
if (!value) value = null;
|
||||
else if (value === "true") value = true;
|
||||
else if (value === "false") value = false;
|
||||
else if (value === "NaN") value = NaN;
|
||||
else if (!isNaN(number = +value)) value = number;
|
||||
else if (m = value.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)) {
|
||||
if (fixtz && !!m[4] && !m[7]) value = value.replace(/-/g, "/").replace(/T/, " ");
|
||||
value = new Date(value);
|
||||
}
|
||||
else continue;
|
||||
object[key] = value;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
// https://github.com/d3/d3-dsv/issues/45
|
||||
var fixtz = new Date("2019-01-01T00:00").getHours() || new Date("2019-07-01T00:00").getHours();
|
||||
11
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/csv.js
generated
vendored
Normal file
11
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/csv.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import dsv from "./dsv.js";
|
||||
|
||||
var csv = dsv(",");
|
||||
|
||||
export var csvParse = csv.parse;
|
||||
export var csvParseRows = csv.parseRows;
|
||||
export var csvFormat = csv.format;
|
||||
export var csvFormatBody = csv.formatBody;
|
||||
export var csvFormatRows = csv.formatRows;
|
||||
export var csvFormatRow = csv.formatRow;
|
||||
export var csvFormatValue = csv.formatValue;
|
||||
164
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/dsv.js
generated
vendored
Normal file
164
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/dsv.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
var EOL = {},
|
||||
EOF = {},
|
||||
QUOTE = 34,
|
||||
NEWLINE = 10,
|
||||
RETURN = 13;
|
||||
|
||||
function objectConverter(columns) {
|
||||
return new Function("d", "return {" + columns.map(function(name, i) {
|
||||
return JSON.stringify(name) + ": d[" + i + "] || \"\"";
|
||||
}).join(",") + "}");
|
||||
}
|
||||
|
||||
function customConverter(columns, f) {
|
||||
var object = objectConverter(columns);
|
||||
return function(row, i) {
|
||||
return f(object(row), i, columns);
|
||||
};
|
||||
}
|
||||
|
||||
// Compute unique columns in order of discovery.
|
||||
function inferColumns(rows) {
|
||||
var columnSet = Object.create(null),
|
||||
columns = [];
|
||||
|
||||
rows.forEach(function(row) {
|
||||
for (var column in row) {
|
||||
if (!(column in columnSet)) {
|
||||
columns.push(columnSet[column] = column);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
function pad(value, width) {
|
||||
var s = value + "", length = s.length;
|
||||
return length < width ? new Array(width - length + 1).join(0) + s : s;
|
||||
}
|
||||
|
||||
function formatYear(year) {
|
||||
return year < 0 ? "-" + pad(-year, 6)
|
||||
: year > 9999 ? "+" + pad(year, 6)
|
||||
: pad(year, 4);
|
||||
}
|
||||
|
||||
function formatDate(date) {
|
||||
var hours = date.getUTCHours(),
|
||||
minutes = date.getUTCMinutes(),
|
||||
seconds = date.getUTCSeconds(),
|
||||
milliseconds = date.getUTCMilliseconds();
|
||||
return isNaN(date) ? "Invalid Date"
|
||||
: formatYear(date.getUTCFullYear(), 4) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2)
|
||||
+ (milliseconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "." + pad(milliseconds, 3) + "Z"
|
||||
: seconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "Z"
|
||||
: minutes || hours ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + "Z"
|
||||
: "");
|
||||
}
|
||||
|
||||
export default function(delimiter) {
|
||||
var reFormat = new RegExp("[\"" + delimiter + "\n\r]"),
|
||||
DELIMITER = delimiter.charCodeAt(0);
|
||||
|
||||
function parse(text, f) {
|
||||
var convert, columns, rows = parseRows(text, function(row, i) {
|
||||
if (convert) return convert(row, i - 1);
|
||||
columns = row, convert = f ? customConverter(row, f) : objectConverter(row);
|
||||
});
|
||||
rows.columns = columns || [];
|
||||
return rows;
|
||||
}
|
||||
|
||||
function parseRows(text, f) {
|
||||
var rows = [], // output rows
|
||||
N = text.length,
|
||||
I = 0, // current character index
|
||||
n = 0, // current line number
|
||||
t, // current token
|
||||
eof = N <= 0, // current token followed by EOF?
|
||||
eol = false; // current token followed by EOL?
|
||||
|
||||
// Strip the trailing newline.
|
||||
if (text.charCodeAt(N - 1) === NEWLINE) --N;
|
||||
if (text.charCodeAt(N - 1) === RETURN) --N;
|
||||
|
||||
function token() {
|
||||
if (eof) return EOF;
|
||||
if (eol) return eol = false, EOL;
|
||||
|
||||
// Unescape quotes.
|
||||
var i, j = I, c;
|
||||
if (text.charCodeAt(j) === QUOTE) {
|
||||
while (I++ < N && text.charCodeAt(I) !== QUOTE || text.charCodeAt(++I) === QUOTE);
|
||||
if ((i = I) >= N) eof = true;
|
||||
else if ((c = text.charCodeAt(I++)) === NEWLINE) eol = true;
|
||||
else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; }
|
||||
return text.slice(j + 1, i - 1).replace(/""/g, "\"");
|
||||
}
|
||||
|
||||
// Find next delimiter or newline.
|
||||
while (I < N) {
|
||||
if ((c = text.charCodeAt(i = I++)) === NEWLINE) eol = true;
|
||||
else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; }
|
||||
else if (c !== DELIMITER) continue;
|
||||
return text.slice(j, i);
|
||||
}
|
||||
|
||||
// Return last token before EOF.
|
||||
return eof = true, text.slice(j, N);
|
||||
}
|
||||
|
||||
while ((t = token()) !== EOF) {
|
||||
var row = [];
|
||||
while (t !== EOL && t !== EOF) row.push(t), t = token();
|
||||
if (f && (row = f(row, n++)) == null) continue;
|
||||
rows.push(row);
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
function preformatBody(rows, columns) {
|
||||
return rows.map(function(row) {
|
||||
return columns.map(function(column) {
|
||||
return formatValue(row[column]);
|
||||
}).join(delimiter);
|
||||
});
|
||||
}
|
||||
|
||||
function format(rows, columns) {
|
||||
if (columns == null) columns = inferColumns(rows);
|
||||
return [columns.map(formatValue).join(delimiter)].concat(preformatBody(rows, columns)).join("\n");
|
||||
}
|
||||
|
||||
function formatBody(rows, columns) {
|
||||
if (columns == null) columns = inferColumns(rows);
|
||||
return preformatBody(rows, columns).join("\n");
|
||||
}
|
||||
|
||||
function formatRows(rows) {
|
||||
return rows.map(formatRow).join("\n");
|
||||
}
|
||||
|
||||
function formatRow(row) {
|
||||
return row.map(formatValue).join(delimiter);
|
||||
}
|
||||
|
||||
function formatValue(value) {
|
||||
return value == null ? ""
|
||||
: value instanceof Date ? formatDate(value)
|
||||
: reFormat.test(value += "") ? "\"" + value.replace(/"/g, "\"\"") + "\""
|
||||
: value;
|
||||
}
|
||||
|
||||
return {
|
||||
parse: parse,
|
||||
parseRows: parseRows,
|
||||
format: format,
|
||||
formatBody: formatBody,
|
||||
formatRows: formatRows,
|
||||
formatRow: formatRow,
|
||||
formatValue: formatValue
|
||||
};
|
||||
}
|
||||
4
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/index.js
generated
vendored
Normal file
4
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export {default as dsvFormat} from "./dsv.js";
|
||||
export {csvParse, csvParseRows, csvFormat, csvFormatBody, csvFormatRows, csvFormatRow, csvFormatValue} from "./csv.js";
|
||||
export {tsvParse, tsvParseRows, tsvFormat, tsvFormatBody, tsvFormatRows, tsvFormatRow, tsvFormatValue} from "./tsv.js";
|
||||
export {default as autoType} from "./autoType.js";
|
||||
11
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/tsv.js
generated
vendored
Normal file
11
lisp/emacs-application-framework/app/mermaid/node_modules/d3-dsv/src/tsv.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import dsv from "./dsv.js";
|
||||
|
||||
var tsv = dsv("\t");
|
||||
|
||||
export var tsvParse = tsv.parse;
|
||||
export var tsvParseRows = tsv.parseRows;
|
||||
export var tsvFormat = tsv.format;
|
||||
export var tsvFormatBody = tsv.formatBody;
|
||||
export var tsvFormatRows = tsv.formatRows;
|
||||
export var tsvFormatRow = tsv.formatRow;
|
||||
export var tsvFormatValue = tsv.formatValue;
|
||||
Reference in New Issue
Block a user