soda-js
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -1,4 +0,5 @@ | ||
// Generated by CoffeeScript 1.6.3 | ||
var Connection, Consumer, Dataset, EventEmitter, Operation, Producer, Query, addExpr, base64Lookup, expr, extend, handleLiteral, handleOrder, httpClient, isArray, isNumber, isString, rawToBase64, toBase64, | ||
__slice = [].slice; | ||
// Generated by CoffeeScript 1.10.0 | ||
var Connection, Consumer, Dataset, EventEmitter, Operation, Producer, Query, addExpr, base64Lookup, expr, extend, handleLiteral, handleOrder, httpClient, isArray, isNumber, isString, rawToBase64, toBase64, toQuerystring, | ||
slice = [].slice, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -22,6 +23,6 @@ EventEmitter = require('eventemitter2').EventEmitter2; | ||
extend = function() { | ||
var k, source, sources, target, v, _i, _len; | ||
target = arguments[0], sources = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
for (_i = 0, _len = sources.length; _i < _len; _i++) { | ||
source = sources[_i]; | ||
var j, k, len, source, sources, target, v; | ||
target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
for (j = 0, len = sources.length; j < len; j++) { | ||
source = sources[j]; | ||
for (k in source) { | ||
@@ -86,21 +87,21 @@ v = source[k]; | ||
addExpr = function(target, args) { | ||
var arg, k, v, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = args.length; _i < _len; _i++) { | ||
arg = args[_i]; | ||
var arg, j, k, len, results, v; | ||
results = []; | ||
for (j = 0, len = args.length; j < len; j++) { | ||
arg = args[j]; | ||
if (isString(arg)) { | ||
_results.push(target.push(arg)); | ||
results.push(target.push(arg)); | ||
} else { | ||
_results.push((function() { | ||
var _results1; | ||
_results1 = []; | ||
results.push((function() { | ||
var results1; | ||
results1 = []; | ||
for (k in arg) { | ||
v = arg[k]; | ||
_results1.push(target.push("" + k + " = " + (handleLiteral(v)))); | ||
results1.push(target.push(k + " = " + (handleLiteral(v)))); | ||
} | ||
return _results1; | ||
return results1; | ||
})()); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -111,11 +112,11 @@ | ||
var clause, clauses; | ||
clauses = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
clauses = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return ((function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = clauses.length; _i < _len; _i++) { | ||
clause = clauses[_i]; | ||
_results.push("(" + clause + ")"); | ||
var j, len, results; | ||
results = []; | ||
for (j = 0, len = clauses.length; j < len; j++) { | ||
clause = clauses[j]; | ||
results.push("(" + clause + ")"); | ||
} | ||
return _results; | ||
return results; | ||
})()).join(' and '); | ||
@@ -125,33 +126,44 @@ }, | ||
var clause, clauses; | ||
clauses = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
clauses = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return ((function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = clauses.length; _i < _len; _i++) { | ||
clause = clauses[_i]; | ||
_results.push("(" + clause + ")"); | ||
var j, len, results; | ||
results = []; | ||
for (j = 0, len = clauses.length; j < len; j++) { | ||
clause = clauses[j]; | ||
results.push("(" + clause + ")"); | ||
} | ||
return _results; | ||
return results; | ||
})()).join(' or '); | ||
}, | ||
gt: function(column, literal) { | ||
return "" + column + " > " + (handleLiteral(literal)); | ||
return column + " > " + (handleLiteral(literal)); | ||
}, | ||
gte: function(column, literal) { | ||
return "" + column + " >= " + (handleLiteral(literal)); | ||
return column + " >= " + (handleLiteral(literal)); | ||
}, | ||
lt: function(column, literal) { | ||
return "" + column + " < " + (handleLiteral(literal)); | ||
return column + " < " + (handleLiteral(literal)); | ||
}, | ||
lte: function(column, literal) { | ||
return "" + column + " <= " + (handleLiteral(literal)); | ||
return column + " <= " + (handleLiteral(literal)); | ||
}, | ||
eq: function(column, literal) { | ||
return "" + column + " = " + (handleLiteral(literal)); | ||
return column + " = " + (handleLiteral(literal)); | ||
} | ||
}; | ||
toQuerystring = function(obj) { | ||
var key, str, val; | ||
str = []; | ||
for (key in obj) { | ||
if (!hasProp.call(obj, key)) continue; | ||
val = obj[key]; | ||
str.push(encodeURIComponent(key) + '=' + encodeURIComponent(val)); | ||
} | ||
return str.join('&'); | ||
}; | ||
Connection = (function() { | ||
function Connection(dataSite, sodaOpts) { | ||
var _ref; | ||
var ref; | ||
this.dataSite = dataSite; | ||
@@ -162,3 +174,3 @@ this.sodaOpts = sodaOpts != null ? sodaOpts : {}; | ||
} | ||
this.emitterOpts = (_ref = this.sodaOpts.emitterOpts) != null ? _ref : { | ||
this.emitterOpts = (ref = this.sodaOpts.emitterOpts) != null ? ref : { | ||
wildcard: true, | ||
@@ -169,4 +181,3 @@ delimiter: '.', | ||
this.networker = function(opts, data) { | ||
var client, url, | ||
_this = this; | ||
var client, url; | ||
url = "https://" + this.dataSite + opts.path; | ||
@@ -184,3 +195,3 @@ client = httpClient(opts.method, url); | ||
if ((this.sodaOpts.username != null) && (this.sodaOpts.password != null)) { | ||
client.set('Authorization', "Basic " + toBase64("" + this.sodaOpts.username + ":" + this.sodaOpts.password)); | ||
client.set('Authorization', "Basic " + toBase64(this.sodaOpts.username + ":" + this.sodaOpts.password)); | ||
} | ||
@@ -196,5 +207,7 @@ if (this.sodaOpts.accessToken != null) { | ||
} | ||
return function(responseHandler) { | ||
return client.end(responseHandler || _this.getDefaultHandler()); | ||
}; | ||
return (function(_this) { | ||
return function(responseHandler) { | ||
return client.end(responseHandler || _this.getDefaultHandler()); | ||
}; | ||
})(this); | ||
}; | ||
@@ -206,4 +219,4 @@ } | ||
this.emitter = emitter = new EventEmitter(this.emitterOpts); | ||
return handler = function(response) { | ||
var _ref; | ||
return handler = function(error, response) { | ||
var ref; | ||
if (response.ok) { | ||
@@ -219,3 +232,3 @@ if (response.accepted) { | ||
} else { | ||
emitter.emit('error', (_ref = response.body) != null ? _ref : response.text); | ||
emitter.emit('error', (ref = response.body) != null ? ref : response.text); | ||
} | ||
@@ -234,3 +247,3 @@ return emitter.emit('complete', response); | ||
this.sodaOpts = sodaOpts != null ? sodaOpts : {}; | ||
this.connection = new Connection(dataSite, sodaOpts); | ||
this.connection = new Connection(this.dataSite, this.sodaOpts); | ||
} | ||
@@ -255,3 +268,3 @@ | ||
this.sodaOpts = sodaOpts != null ? sodaOpts : {}; | ||
this.connection = new Connection(dataSite, sodaOpts); | ||
this.connection = new Connection(this.dataSite, this.sodaOpts); | ||
} | ||
@@ -287,3 +300,3 @@ | ||
Operation.prototype.add = function(data) { | ||
var obj, opts, _data, _i, _len; | ||
var _data, j, len, obj, opts; | ||
opts = { | ||
@@ -296,4 +309,4 @@ method: 'post' | ||
delete _data[':delete']; | ||
for (_i = 0, _len = _data.length; _i < _len; _i++) { | ||
obj = _data[_i]; | ||
for (j = 0, len = _data.length; j < len; j++) { | ||
obj = _data[j]; | ||
delete obj[':id']; | ||
@@ -361,3 +374,3 @@ delete obj[':delete']; | ||
this._order = []; | ||
this._offset = this._limit = null; | ||
this._offset = this._limit = this._q = null; | ||
} | ||
@@ -376,6 +389,6 @@ | ||
Query.prototype.select = function() { | ||
var select, selects, _i, _len; | ||
selects = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
for (_i = 0, _len = selects.length; _i < _len; _i++) { | ||
select = selects[_i]; | ||
var j, len, select, selects; | ||
selects = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
for (j = 0, len = selects.length; j < len; j++) { | ||
select = selects[j]; | ||
this._select.push(select); | ||
@@ -388,3 +401,3 @@ } | ||
var args; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
args = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
addExpr(this._where, args); | ||
@@ -396,3 +409,3 @@ return this; | ||
var args; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
args = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
addExpr(this._having, args); | ||
@@ -403,6 +416,6 @@ return this; | ||
Query.prototype.group = function() { | ||
var group, groups, _i, _len; | ||
groups = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
for (_i = 0, _len = groups.length; _i < _len; _i++) { | ||
group = groups[_i]; | ||
var group, groups, j, len; | ||
groups = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
for (j = 0, len = groups.length; j < len; j++) { | ||
group = groups[j]; | ||
this._group.push(group); | ||
@@ -414,6 +427,6 @@ } | ||
Query.prototype.order = function() { | ||
var order, orders, _i, _len; | ||
orders = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
for (_i = 0, _len = orders.length; _i < _len; _i++) { | ||
order = orders[_i]; | ||
var j, len, order, orders; | ||
orders = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
for (j = 0, len = orders.length; j < len; j++) { | ||
order = orders[j]; | ||
this._order.push(handleOrder(order)); | ||
@@ -434,3 +447,8 @@ } | ||
Query.prototype.getRows = function() { | ||
Query.prototype.q = function(q) { | ||
this._q = q; | ||
return this; | ||
}; | ||
Query.prototype.getOpts = function() { | ||
var k, opts, queryComponents, v; | ||
@@ -450,2 +468,15 @@ opts = { | ||
} | ||
return opts; | ||
}; | ||
Query.prototype.getURL = function() { | ||
var opts, query; | ||
opts = this.getOpts(); | ||
query = toQuerystring(opts.query); | ||
return ("https://" + this.consumer.dataSite + opts.path) + (query ? "?" + query : ""); | ||
}; | ||
Query.prototype.getRows = function() { | ||
var opts; | ||
opts = this.getOpts(); | ||
this.consumer.connection.networker(opts)(); | ||
@@ -485,2 +516,5 @@ return this.consumer.connection.emitter; | ||
} | ||
if (this._q) { | ||
query.q = this._q; | ||
} | ||
} | ||
@@ -495,5 +529,5 @@ return query; | ||
Dataset = (function() { | ||
function Dataset(data, client) { | ||
this.data = data; | ||
this.client = client; | ||
function Dataset(data1, client1) { | ||
this.data = data1; | ||
this.client = client1; | ||
} | ||
@@ -500,0 +534,0 @@ |
@@ -7,11 +7,21 @@ { | ||
"contributors": [{ "name": "Clint Tseng", "email": "clint.tseng@socrata.com" }], | ||
"dependencies": [ "superagent", "eventemitter2" ], | ||
"homepage": "https://github.com/socrata/soda-js", | ||
"devDependencies": [ "coffee-script", "expresso" ], | ||
"dependencies": { | ||
"eventemitter2": "~0.4.14", | ||
"superagent": "~0.21.0" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "~1.6.3", | ||
"expresso": "~0.9.2", | ||
"browserify": "^12.0.1" | ||
}, | ||
"licenses": [{ "type": "MIT" }], | ||
"scripts": { | ||
"test": "expresso test/*" | ||
"test": "node_modules/expresso/bin/expresso test/*", | ||
"coffee": "node_modules/coffee-script/bin/cake build", | ||
"bundle": "browserify lib/soda-js.js --standalone soda > lib/soda-js.bundle.js", | ||
"build": "npm run coffee && npm run bundle" | ||
}, | ||
"main": "./lib/soda-js.js", | ||
"version": "0.2.1" | ||
"version": "0.2.2" | ||
} |
@@ -1,7 +0,7 @@ | ||
var soda = require('soda-js'); | ||
var soda = require('../lib/soda-js'); | ||
var consumer = new soda.Consumer('explore.data.gov'); | ||
var consumer = new soda.Consumer('open.whitehouse.gov'); | ||
consumer.query() | ||
.withDataset('644b-gaut') | ||
.withDataset('p86s-ychb') | ||
.limit(5) | ||
@@ -8,0 +8,0 @@ .where({ namelast: 'SMITH' }) |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 2 instances in 1 package
Bad dependency semver
QualityPackage has dependencies with an invalid semantic version. This could be a sign of beta, low quality, or unmaintained dependencies.
Found 2 instances in 1 package
146994
17
4109
1
1
3
3
+ Addedeventemitter2@~0.4.14
+ Addedsuperagent@~0.21.0
+ Addedasync@0.9.2(transitive)
+ Addedcombined-stream@0.0.7(transitive)
+ Addedcomponent-emitter@1.1.2(transitive)
+ Addedcookiejar@2.0.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddelayed-stream@0.0.5(transitive)
+ Addedeventemitter2@0.4.14(transitive)
+ Addedextend@1.2.1(transitive)
+ Addedform-data@0.1.3(transitive)
+ Addedformidable@1.0.14(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedmethods@1.0.1(transitive)
+ Addedmime@1.2.11(transitive)
+ Addedms@2.0.0(transitive)
+ Addedqs@1.2.0(transitive)
+ Addedreadable-stream@1.0.27-1(transitive)
+ Addedreduce-component@1.0.1(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedsuperagent@0.21.0(transitive)
- Removed0@superagent
- Removed1@eventemitter2