mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 15:31:52 +00:00
config redirect
This commit is contained in:
+233
@@ -0,0 +1,233 @@
|
||||
// https://d3js.org/d3-dsv/ v3.0.1 Copyright 2013-2021 Mike Bostock
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
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()) + "-" + 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"
|
||||
: "");
|
||||
}
|
||||
|
||||
function dsv(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
|
||||
};
|
||||
}
|
||||
|
||||
var csv = dsv(",");
|
||||
|
||||
var csvParse = csv.parse;
|
||||
var csvParseRows = csv.parseRows;
|
||||
var csvFormat = csv.format;
|
||||
var csvFormatBody = csv.formatBody;
|
||||
var csvFormatRows = csv.formatRows;
|
||||
var csvFormatRow = csv.formatRow;
|
||||
var csvFormatValue = csv.formatValue;
|
||||
|
||||
var tsv = dsv("\t");
|
||||
|
||||
var tsvParse = tsv.parse;
|
||||
var tsvParseRows = tsv.parseRows;
|
||||
var tsvFormat = tsv.format;
|
||||
var tsvFormatBody = tsv.formatBody;
|
||||
var tsvFormatRows = tsv.formatRows;
|
||||
var tsvFormatRow = tsv.formatRow;
|
||||
var tsvFormatValue = tsv.formatValue;
|
||||
|
||||
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
|
||||
const fixtz = new Date("2019-01-01T00:00").getHours() || new Date("2019-07-01T00:00").getHours();
|
||||
|
||||
exports.autoType = autoType;
|
||||
exports.csvFormat = csvFormat;
|
||||
exports.csvFormatBody = csvFormatBody;
|
||||
exports.csvFormatRow = csvFormatRow;
|
||||
exports.csvFormatRows = csvFormatRows;
|
||||
exports.csvFormatValue = csvFormatValue;
|
||||
exports.csvParse = csvParse;
|
||||
exports.csvParseRows = csvParseRows;
|
||||
exports.dsvFormat = dsv;
|
||||
exports.tsvFormat = tsvFormat;
|
||||
exports.tsvFormatBody = tsvFormatBody;
|
||||
exports.tsvFormatRow = tsvFormatRow;
|
||||
exports.tsvFormatRows = tsvFormatRows;
|
||||
exports.tsvFormatValue = tsvFormatValue;
|
||||
exports.tsvParse = tsvParse;
|
||||
exports.tsvParseRows = tsvParseRows;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// https://d3js.org/d3-dsv/ v3.0.1 Copyright 2013-2021 Mike Bostock
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3=e.d3||{})}(this,(function(e){"use strict";var t={},r={};function n(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function o(e){var t=Object.create(null),r=[];return e.forEach((function(e){for(var n in e)n in t||r.push(t[n]=n)})),r}function a(e,t){var r=e+"",n=r.length;return n<t?new Array(t-n+1).join(0)+r:r}function u(e){var t,r=e.getUTCHours(),n=e.getUTCMinutes(),o=e.getUTCSeconds(),u=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+a(-t,6):t>9999?"+"+a(t,6):a(t,4))+"-"+a(e.getUTCMonth()+1,2)+"-"+a(e.getUTCDate(),2)+(u?"T"+a(r,2)+":"+a(n,2)+":"+a(o,2)+"."+a(u,3)+"Z":o?"T"+a(r,2)+":"+a(n,2)+":"+a(o,2)+"Z":n||r?"T"+a(r,2)+":"+a(n,2)+"Z":"")}function i(e){var a=new RegExp('["'+e+"\n\r]"),i=e.charCodeAt(0);function f(e,n){var o,a=[],u=e.length,f=0,s=0,c=u<=0,l=!1;function d(){if(c)return r;if(l)return l=!1,t;var n,o,a=f;if(34===e.charCodeAt(a)){for(;f++<u&&34!==e.charCodeAt(f)||34===e.charCodeAt(++f););return(n=f)>=u?c=!0:10===(o=e.charCodeAt(f++))?l=!0:13===o&&(l=!0,10===e.charCodeAt(f)&&++f),e.slice(a+1,n-1).replace(/""/g,'"')}for(;f<u;){if(10===(o=e.charCodeAt(n=f++)))l=!0;else if(13===o)l=!0,10===e.charCodeAt(f)&&++f;else if(o!==i)continue;return e.slice(a,n)}return c=!0,e.slice(a,u)}for(10===e.charCodeAt(u-1)&&--u,13===e.charCodeAt(u-1)&&--u;(o=d())!==r;){for(var m=[];o!==t&&o!==r;)m.push(o),o=d();n&&null==(m=n(m,s++))||a.push(m)}return a}function s(t,r){return t.map((function(t){return r.map((function(e){return l(t[e])})).join(e)}))}function c(t){return t.map(l).join(e)}function l(e){return null==e?"":e instanceof Date?u(e):a.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var r,o,a=f(e,(function(e,a){if(r)return r(e,a-1);o=e,r=t?function(e,t){var r=n(e);return function(n,o){return t(r(n),o,e)}}(e,t):n(e)}));return a.columns=o||[],a},parseRows:f,format:function(t,r){return null==r&&(r=o(t)),[r.map(l).join(e)].concat(s(t,r)).join("\n")},formatBody:function(e,t){return null==t&&(t=o(e)),s(e,t).join("\n")},formatRows:function(e){return e.map(c).join("\n")},formatRow:c,formatValue:l}}var f=i(","),s=f.parse,c=f.parseRows,l=f.format,d=f.formatBody,m=f.formatRows,v=f.formatRow,p=f.formatValue,h=i("\t"),w=h.parse,g=h.parseRows,C=h.format,T=h.formatBody,R=h.formatRows,y=h.formatRow,F=h.formatValue;const j=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();e.autoType=function(e){for(var t in e){var r,n,o=e[t].trim();if(o)if("true"===o)o=!0;else if("false"===o)o=!1;else if("NaN"===o)o=NaN;else if(isNaN(r=+o)){if(!(n=o.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;j&&n[4]&&!n[7]&&(o=o.replace(/-/g,"/").replace(/T/," ")),o=new Date(o)}else o=r;else o=null;e[t]=o}return e},e.csvFormat=l,e.csvFormatBody=d,e.csvFormatRow=v,e.csvFormatRows=m,e.csvFormatValue=p,e.csvParse=s,e.csvParseRows=c,e.dsvFormat=i,e.tsvFormat=C,e.tsvFormatBody=T,e.tsvFormatRow=y,e.tsvFormatRows=R,e.tsvFormatValue=F,e.tsvParse=w,e.tsvParseRows=g,Object.defineProperty(e,"__esModule",{value:!0})}));
|
||||
Reference in New Issue
Block a user