Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-dsv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-dsv - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

264

angular-dsv.js

@@ -6,3 +6,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.angularDsv = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var d3DSV = require('d3-dsv').dsv;
var d3DSV = require('d3-dsv').dsvFormat;

@@ -27,4 +27,4 @@ function parseParams (requestConfig, f) {

method: 'get',
transformResponse: function (data) {
return data === null ? [] : _dsv.parse(data, f);
transformResponse: function (data, headers, status) {
return status >= 200 && status < 300 ? _dsv.parse(data, f) : [];
}

@@ -59,4 +59,4 @@ };

url: url,
transformResponse: function (data) {
return data === null ? [] : _dsv.parseRows(data, params.f);
transformResponse: function (data, headers, status) {
return status >= 200 && status < 300 ? _dsv.parseRows(data, params.f) : [];
}

@@ -86,152 +86,172 @@ };

},{"d3-dsv":2}],2:[function(require,module,exports){
// https://d3js.org/d3-dsv/ Version 1.0.3. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3_dsv = {})));
}(this, function (exports) { 'use strict';
(factory((global.d3 = global.d3 || {})));
}(this, (function (exports) { 'use strict';
function dsv(delimiter) {
return new Dsv(delimiter);
}
function objectConverter(columns) {
return new Function("d", "return {" + columns.map(function(name, i) {
return JSON.stringify(name) + ": d[" + i + "]";
}).join(",") + "}");
}
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);
};
}
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 = [];
// 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);
}
rows.forEach(function(row) {
for (var column in row) {
if (!(column in columnSet)) {
columns.push(columnSet[column] = column);
}
});
}
});
return columns;
}
return columns;
}
function Dsv(delimiter) {
var reFormat = new RegExp("[\"" + delimiter + "\n]"),
delimiterCode = delimiter.charCodeAt(0);
function dsv(delimiter) {
var reFormat = new RegExp("[\"" + delimiter + "\n]"),
delimiterCode = delimiter.charCodeAt(0);
this.parse = function(text, f) {
var convert, columns, rows = this.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 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;
}
this.parseRows = function(text, f) {
var EOL = {}, // sentinel value for end-of-line
EOF = {}, // sentinel value for end-of-file
rows = [], // output rows
N = text.length,
I = 0, // current character index
n = 0, // the current line number
t, // the current token
eol; // is the current token followed by EOL?
function parseRows(text, f) {
var EOL = {}, // sentinel value for end-of-line
EOF = {}, // sentinel value for end-of-file
rows = [], // output rows
N = text.length,
I = 0, // current character index
n = 0, // the current line number
t, // the current token
eol; // is the current token followed by EOL?
function token() {
if (I >= N) return EOF; // special case: end of file
if (eol) return eol = false, EOL; // special case: end of line
function token() {
if (I >= N) return EOF; // special case: end of file
if (eol) return eol = false, EOL; // special case: end of line
// special case: quotes
var j = I, c;
if (text.charCodeAt(j) === 34) {
var i = j;
while (i++ < N) {
if (text.charCodeAt(i) === 34) {
if (text.charCodeAt(i + 1) !== 34) break;
++i;
}
// special case: quotes
var j = I, c;
if (text.charCodeAt(j) === 34) {
var i = j;
while (i++ < N) {
if (text.charCodeAt(i) === 34) {
if (text.charCodeAt(i + 1) !== 34) break;
++i;
}
I = i + 2;
c = text.charCodeAt(i + 1);
if (c === 13) {
eol = true;
if (text.charCodeAt(i + 2) === 10) ++I;
} else if (c === 10) {
eol = true;
}
return text.slice(j + 1, i).replace(/""/g, "\"");
}
// common case: find next delimiter or newline
while (I < N) {
var k = 1;
c = text.charCodeAt(I++);
if (c === 10) eol = true; // \n
else if (c === 13) { eol = true; if (text.charCodeAt(I) === 10) ++I, ++k; } // \r|\r\n
else if (c !== delimiterCode) continue;
return text.slice(j, I - k);
I = i + 2;
c = text.charCodeAt(i + 1);
if (c === 13) {
eol = true;
if (text.charCodeAt(i + 2) === 10) ++I;
} else if (c === 10) {
eol = true;
}
// special case: last token before EOF
return text.slice(j);
return text.slice(j + 1, i).replace(/""/g, "\"");
}
while ((t = token()) !== EOF) {
var a = [];
while (t !== EOL && t !== EOF) {
a.push(t);
t = token();
}
if (f && (a = f(a, n++)) == null) continue;
rows.push(a);
// common case: find next delimiter or newline
while (I < N) {
var k = 1;
c = text.charCodeAt(I++);
if (c === 10) eol = true; // \n
else if (c === 13) { eol = true; if (text.charCodeAt(I) === 10) ++I, ++k; } // \r|\r\n
else if (c !== delimiterCode) continue;
return text.slice(j, I - k);
}
return rows;
// special case: last token before EOF
return text.slice(j);
}
this.format = function(rows, columns) {
if (columns == null) columns = inferColumns(rows);
return [columns.map(formatValue).join(delimiter)].concat(rows.map(function(row) {
return columns.map(function(column) {
return formatValue(row[column]);
}).join(delimiter);
})).join("\n");
};
while ((t = token()) !== EOF) {
var a = [];
while (t !== EOL && t !== EOF) {
a.push(t);
t = token();
}
if (f && (a = f(a, n++)) == null) continue;
rows.push(a);
}
this.formatRows = function(rows) {
return rows.map(formatRow).join("\n");
};
return rows;
}
function formatRow(row) {
return row.map(formatValue).join(delimiter);
}
function format(rows, columns) {
if (columns == null) columns = inferColumns(rows);
return [columns.map(formatValue).join(delimiter)].concat(rows.map(function(row) {
return columns.map(function(column) {
return formatValue(row[column]);
}).join(delimiter);
})).join("\n");
}
function formatValue(text) {
return reFormat.test(text) ? "\"" + text.replace(/\"/g, "\"\"") + "\"" : text;
}
function formatRows(rows) {
return rows.map(formatRow).join("\n");
}
dsv.prototype = Dsv.prototype;
function formatRow(row) {
return row.map(formatValue).join(delimiter);
}
var csv = dsv(",");
var tsv = dsv("\t");
function formatValue(text) {
return text == null ? ""
: reFormat.test(text += "") ? "\"" + text.replace(/\"/g, "\"\"") + "\""
: text;
}
var version = "0.1.14";
return {
parse: parse,
parseRows: parseRows,
format: format,
formatRows: formatRows
};
}
exports.version = version;
exports.dsv = dsv;
exports.csv = csv;
exports.tsv = tsv;
var csv = dsv(",");
}));
var csvParse = csv.parse;
var csvParseRows = csv.parseRows;
var csvFormat = csv.format;
var csvFormatRows = csv.formatRows;
var tsv = dsv("\t");
var tsvParse = tsv.parse;
var tsvParseRows = tsv.parseRows;
var tsvFormat = tsv.format;
var tsvFormatRows = tsv.formatRows;
exports.dsvFormat = dsv;
exports.csvParse = csvParse;
exports.csvParseRows = csvParseRows;
exports.csvFormat = csvFormat;
exports.csvFormatRows = csvFormatRows;
exports.tsvParse = tsvParse;
exports.tsvParseRows = tsvParseRows;
exports.tsvFormat = tsvFormat;
exports.tsvFormatRows = tsvFormatRows;
Object.defineProperty(exports, '__esModule', { value: true });
})));
},{}]},{},[1])(1)
});

@@ -1,1 +0,1 @@

(function(n){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=n()}else if(typeof define==="function"&&define.amd){define([],n)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.angularDsv=n()}})(function(){var n,e,r;return function n(e,r,t){function o(i,f){if(!r[i]){if(!e[i]){var a=typeof require=="function"&&require;if(!f&&a)return a(i,!0);if(u)return u(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var c=r[i]={exports:{}};e[i][0].call(c.exports,function(n){var r=e[i][1][n];return o(r?r:n)},c,c.exports,n,e,r,t)}return r[i].exports}var u=typeof require=="function"&&require;for(var i=0;i<t.length;i++)o(t[i]);return o}({1:[function(n,e,r){"use strict";var t=n("d3-dsv").dsv;function o(n,e){return angular.isFunction(n)?{requestConfig:null,f:n}:{requestConfig:n,f:e}}u.$inject=["$http"];function u(n){function e(e){var r=t(e);function u(e,t){var o={method:"get",transformResponse:function(n){return n===null?[]:r.parse(n,t)}};angular.extend(o,e);return n(o)}u.parseRows=r.parseRows;u.parse=r.parse;u.get=function(n,e,r){var t=o(e,r);var i={method:"get",url:n};return u(angular.extend(i,t.requestConfig),t.f)};u.getRows=function(n,e,t){var i=o(e,t);var f={method:"get",url:n,transformResponse:function(n){return n===null?[]:r.parseRows(n,i.f)}};return u(angular.extend(f,i.requestConfig),i.f)};return u}e.tsv=e("\t");e.csv=e(",");return e}e.exports="hc.dsv";angular.module("hc.dsv",[]).factory("dsv",u)},{"d3-dsv":2}],2:[function(e,r,t){(function(e,o){typeof t==="object"&&typeof r!=="undefined"?o(t):typeof n==="function"&&n.amd?n(["exports"],o):o(e.d3_dsv={})})(this,function(n){"use strict";function e(n){return new u(n)}function r(n){return new Function("d","return {"+n.map(function(n,e){return JSON.stringify(n)+": d["+e+"]"}).join(",")+"}")}function t(n,e){var t=r(n);return function(r,o){return e(t(r),o,n)}}function o(n){var e=Object.create(null),r=[];n.forEach(function(n){for(var t in n){if(!(t in e)){r.push(e[t]=t)}}});return r}function u(n){var e=new RegExp('["'+n+"\n]"),u=n.charCodeAt(0);this.parse=function(n,e){var o,u,i=this.parseRows(n,function(n,i){if(o)return o(n,i-1);u=n,o=e?t(n,e):r(n)});i.columns=u;return i};this.parseRows=function(n,e){var r={},t={},o=[],i=n.length,f=0,a=0,s,c;function l(){if(f>=i)return t;if(c)return c=false,r;var e=f,o;if(n.charCodeAt(e)===34){var a=e;while(a++<i){if(n.charCodeAt(a)===34){if(n.charCodeAt(a+1)!==34)break;++a}}f=a+2;o=n.charCodeAt(a+1);if(o===13){c=true;if(n.charCodeAt(a+2)===10)++f}else if(o===10){c=true}return n.slice(e+1,a).replace(/""/g,'"')}while(f<i){var s=1;o=n.charCodeAt(f++);if(o===10)c=true;else if(o===13){c=true;if(n.charCodeAt(f)===10)++f,++s}else if(o!==u)continue;return n.slice(e,f-s)}return n.slice(e)}while((s=l())!==t){var d=[];while(s!==r&&s!==t){d.push(s);s=l()}if(e&&(d=e(d,a++))==null)continue;o.push(d)}return o};this.format=function(e,r){if(r==null)r=o(e);return[r.map(f).join(n)].concat(e.map(function(e){return r.map(function(n){return f(e[n])}).join(n)})).join("\n")};this.formatRows=function(n){return n.map(i).join("\n")};function i(e){return e.map(f).join(n)}function f(n){return e.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}}e.prototype=u.prototype;var i=e(",");var f=e("\t");var a="0.1.14";n.version=a;n.dsv=e;n.csv=i;n.tsv=f})},{}]},{},[1])(1)});
(function(r){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=r()}else if(typeof define==="function"&&define.amd){define([],r)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.angularDsv=r()}})(function(){var r,e,n;return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var a=typeof require=="function"&&require;if(!f&&a)return a(i,!0);if(u)return u(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[i]={exports:{}};e[i][0].call(c.exports,function(r){var n=e[i][1][r];return o(n?n:r)},c,c.exports,r,e,n,t)}return n[i].exports}var u=typeof require=="function"&&require;for(var i=0;i<t.length;i++)o(t[i]);return o}({1:[function(r,e,n){"use strict";var t=r("d3-dsv").dsvFormat;function o(r,e){return angular.isFunction(r)?{requestConfig:null,f:r}:{requestConfig:r,f:e}}u.$inject=["$http"];function u(r){function e(e){var n=t(e);function u(e,t){var o={method:"get",transformResponse:function(r,e,o){return o>=200&&o<300?n.parse(r,t):[]}};angular.extend(o,e);return r(o)}u.parseRows=n.parseRows;u.parse=n.parse;u.get=function(r,e,n){var t=o(e,n);var i={method:"get",url:r};return u(angular.extend(i,t.requestConfig),t.f)};u.getRows=function(r,e,t){var i=o(e,t);var f={method:"get",url:r,transformResponse:function(r,e,t){return t>=200&&t<300?n.parseRows(r,i.f):[]}};return u(angular.extend(f,i.requestConfig),i.f)};return u}e.tsv=e("\t");e.csv=e(",");return e}e.exports="hc.dsv";angular.module("hc.dsv",[]).factory("dsv",u)},{"d3-dsv":2}],2:[function(e,n,t){(function(e,o){typeof t==="object"&&typeof n!=="undefined"?o(t):typeof r==="function"&&r.amd?r(["exports"],o):o(e.d3=e.d3||{})})(this,function(r){"use strict";function e(r){return new Function("d","return {"+r.map(function(r,e){return JSON.stringify(r)+": d["+e+"]"}).join(",")+"}")}function n(r,n){var t=e(r);return function(e,o){return n(t(e),o,r)}}function t(r){var e=Object.create(null),n=[];r.forEach(function(r){for(var t in r){if(!(t in e)){n.push(e[t]=t)}}});return n}function o(r){var o=new RegExp('["'+r+"\n]"),u=r.charCodeAt(0);function i(r,t){var o,u,i=f(r,function(r,i){if(o)return o(r,i-1);u=r,o=t?n(r,t):e(r)});i.columns=u;return i}function f(r,e){var n={},t={},o=[],i=r.length,f=0,a=0,s,c;function v(){if(f>=i)return t;if(c)return c=false,n;var e=f,o;if(r.charCodeAt(e)===34){var a=e;while(a++<i){if(r.charCodeAt(a)===34){if(r.charCodeAt(a+1)!==34)break;++a}}f=a+2;o=r.charCodeAt(a+1);if(o===13){c=true;if(r.charCodeAt(a+2)===10)++f}else if(o===10){c=true}return r.slice(e+1,a).replace(/""/g,'"')}while(f<i){var s=1;o=r.charCodeAt(f++);if(o===10)c=true;else if(o===13){c=true;if(r.charCodeAt(f)===10)++f,++s}else if(o!==u)continue;return r.slice(e,f-s)}return r.slice(e)}while((s=v())!==t){var l=[];while(s!==n&&s!==t){l.push(s);s=v()}if(e&&(l=e(l,a++))==null)continue;o.push(l)}return o}function a(e,n){if(n==null)n=t(e);return[n.map(v).join(r)].concat(e.map(function(e){return n.map(function(r){return v(e[r])}).join(r)})).join("\n")}function s(r){return r.map(c).join("\n")}function c(e){return e.map(v).join(r)}function v(r){return r==null?"":o.test(r+="")?'"'+r.replace(/\"/g,'""')+'"':r}return{parse:i,parseRows:f,format:a,formatRows:s}}var u=o(",");var i=u.parse;var f=u.parseRows;var a=u.format;var s=u.formatRows;var c=o("\t");var v=c.parse;var l=c.parseRows;var d=c.format;var p=c.formatRows;r.dsvFormat=o;r.csvParse=i;r.csvParseRows=f;r.csvFormat=a;r.csvFormatRows=s;r.tsvParse=v;r.tsvParseRows=l;r.tsvFormat=d;r.tsvFormatRows=p;Object.defineProperty(r,"__esModule",{value:true})})},{}]},{},[1])(1)});

@@ -5,3 +5,3 @@ /* global angular */

var d3DSV = require('d3-dsv').dsv;
var d3DSV = require('d3-dsv').dsvFormat;

@@ -26,4 +26,4 @@ function parseParams (requestConfig, f) {

method: 'get',
transformResponse: function (data) {
return data === null ? [] : _dsv.parse(data, f);
transformResponse: function (data, headers, status) {
return status >= 200 && status < 300 ? _dsv.parse(data, f) : [];
}

@@ -58,4 +58,4 @@ };

url: url,
transformResponse: function (data) {
return data === null ? [] : _dsv.parseRows(data, params.f);
transformResponse: function (data, headers, status) {
return status >= 200 && status < 300 ? _dsv.parseRows(data, params.f) : [];
}

@@ -62,0 +62,0 @@ };

{
"name": "angular-dsv",
"version": "1.0.1",
"version": "1.1.0",
"description": "",

@@ -15,6 +15,6 @@ "main": "lib/angular-dsv.js",

"dependencies": {
"d3-dsv": "^0.1.9"
"d3-dsv": "^1.0.3"
},
"devDependencies": {
"browserify": "^12.0.1",
"browserify": "^13.1.0",
"jasmine-core": "^2.5.2",

@@ -24,7 +24,7 @@ "karma": "^1.3.0",

"karma-phantomjs-launcher": "^1.0.2",
"uglify-js": "^2.6.1",
"uglify-js": "^2.7.3",
"xo": "^0.16.0"
},
"scripts": {
"test": "npm run build && karma start",
"test": "xo && npm run build && karma start",
"uglify": "uglifyjs angular-dsv.js -o angular-dsv.min.js --mangle",

@@ -31,0 +31,0 @@ "browserify": "browserify lib/angular-dsv.js -s angular-dsv -o angular-dsv.js",

@@ -19,11 +19,12 @@ # angular-dsv [![Bower version](https://badge.fury.io/bo/angular-dsv.png)](http://badge.fury.io/bo/angular-dsv)

The `dsv.tsv` service is an example of 'delimiter'-seperated value interface for tab-delimited tables. It is service which takes two arguments: a configuration object like that expected by angular's [$http](https://docs.angularjs.org/api/ng/service/$http), and an optional accessor function for transforming each row of the tabular data file. Like `$http` `dsv.tsv` returns a promise with two "$http specific methods": `.success` and `.error` (in addition to `.then`)
The `dsv.tsv` service is an example of 'delimiter'-seperated value interface for tab-delimited tables. It is service which takes two arguments: a configuration object like that expected by angular's [$http](https://docs.angularjs.org/api/ng/service/$http), and an optional accessor function for transforming each row of the tabular data file. Like `$http` `dsv.tsv` returns a promise:
```(js)
dsv.tsv({method: 'GET', url: '/someUrl'}, function(d) { return {key: d.key, value: +d.value}; })
.success(function(data, status, headers, config) {
.then(function(response) {
console.log(response.data);
// this callback will be called asynchronously
// when the response is available
})
.error(function(data, status, headers, config) {
.catch(function(err) {
// called asynchronously if an error occurs

@@ -56,3 +57,3 @@ // or server returns response with an error status.

```(js)
dsv.tsv.get('/someUrl', accessorFunction).success(successCallback);
dsv.tsv.get('/someUrl', accessorFunction).then(successCallback);
```

@@ -59,0 +60,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc