New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

featureservice

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

featureservice - npm Package Compare versions

Comparing version 1.5.4 to 1.5.5

test/fixtures/stats.json

6

CHANGELOG.md

@@ -5,2 +5,7 @@ # Change Log

## [1.5.5] - 2016-03-31
### Fixed
* Corrected bug in statistics paging strategy
* Exposed `getObjectIdRange` as public function
## [1.5.4] - 2016-03-30

@@ -202,2 +207,3 @@ ### Fixed

[1.5.5]: https://github.com/koopjs/featureservice/compare/v1.5.4...v1.5.5
[1.5.4]: https://github.com/koopjs/featureservice/compare/v1.5.3...v1.5.4

@@ -204,0 +210,0 @@ [1.5.3]: https://github.com/koopjs/featureservice/compare/v1.5.2...v1.5.3

16

index.js

@@ -354,3 +354,3 @@ var queue = require('async').queue

if (layer.supportsStatistics) {
this._getIdRangeFromStats(meta, function (err, stats) {
this.getObjectIdRange(meta.oid, function (err, stats) {
// if this worked then we can pagination using where clauses

@@ -380,11 +380,13 @@ if (!err) return callback(null, this._rangePages(stats, size))

*/
FeatureService.prototype._getIdRangeFromStats = function (meta, callback) {
this.statistics(meta.oid, ['min', 'max'], function (err, stats) {
FeatureService.prototype.getObjectIdRange = function (oidField, callback) {
this.statistics(oidField, ['min', 'max'], function (err, stats) {
// TODO this is handled elsewhere now so move it
if (err) return callback(err)
var eMsg = 'Response from statistics was invalid'
console.log(stats)
if (!stats.features || !stats.features[0] || !stats.features[0].attributes) return callback(new Error(eMsg))
var attrs = stats.features[0].attributes
// dmf: what's up with this third strategy?
var names = stats && stats.fieldAliases ? Object.keys(stats.fieldAliases) : null
var min = attrs.min || attrs.MIN || attrs[names[0]]
var max = attrs.max || attrs.MAX || attrs[names[1]]
var min = attrs['min_' + oidField] || attrs.min || attrs.MIN
var max = attrs['max_' + oidField] || attrs.max || attrs.MAX
if (!typeof min === 'number' && typeof max === 'number') return callback(new Error(eMsg))
callback(null, {min: min, max: max})

@@ -391,0 +393,0 @@ })

{
"name": "featureservice",
"description": "Get all features from an Esri Feature Service",
"version": "1.5.4",
"version": "1.5.5",
"author": "Chris Helm",

@@ -6,0 +6,0 @@ "bugs": {

@@ -19,2 +19,3 @@ var sinon = require('sinon')

var securedFixture = JSON.parse(fs.readFileSync('./test/fixtures/secured.json'))
var statsFixture = JSON.parse(fs.readFileSync('./test/fixtures/stats.json'))

@@ -179,2 +180,17 @@ test('create a service with query strings in the parameters', function (t) {

test('get the range of object ids for a service', function (t) {
sinon.stub(service, 'request', function (url, callback) {
callback(null, statsFixture)
})
service.getObjectIdRange('id', function (err, range) {
t.equal(err, null)
var expected = 'http://koop.dc.esri.com/socrata/seattle/2tje-83f6/FeatureServer/1/query?f=json&outFields=&outStatistics=[{"statisticType":"min","onStatisticField":"id","outStatisticFieldName":"min_id"},{"statisticType":"max","onStatisticField":"id","outStatisticFieldName":"max_id"}]'
t.equal(service.request.calledWith(expected), true)
t.equal(range.min, 1)
t.equal(range.max, 14)
service.request.restore()
t.end()
})
})
test('get the feature count for a layer on the service', function (t) {

@@ -181,0 +197,0 @@ sinon.stub(service, 'request', function (url, callback) {

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