Socket
Book a DemoInstallSign in
Socket

double-double-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

double-double-wrapper

A wrapper for in-n-out to add resharing and caching of geofences without intermixing with usage logic

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

stable NPM version Build Status Coverage Status Dependency Status

double-double-wrapper

A wrapper for in-n-out to add resharing and caching of geofences without intermixing with usage logic

Example

var DoubleDoubleWrapper = require("double-double-wrapper");

var doubleDouble = new DoubleDoubleWrapper({
    cache: undefined // set this to an ES6 map-like object (async instead of sync, though)
});                  // if you want a different caching store

doubleDouble.getGeofence('geofenceName', verticesArrayofArrays, granularityInteger, function(err, geofence) {
    geofence.inside([0, 0]); // Boolean true/false indicating whether or not that point is in the polygon
});

doubleDouble.getGeofence('geofenceName', function(err, geofence) {
    console.log('after being defined, only need to reference by id');
});

doubleDouble.geoGeofence('geofence2', verticesArrayofArrays, function(err, geofence) {
    console.log('the granularity is not needed, but is useful for tuning the fast lookup table');
});

doubleDouble.getGeofenceGroup('groupOfGeofences', {
    regionA: {
        whiteoutGfs: [{
            vertices: regionToInclude,
            granularity: granularity1
        }, {
            vertices: anotherRegionToInclude
        }],
        blackoutGfs: [{
            vertices: regionToExclude
        }]
    },
    regionB: {
        whiteoutGfs: [{
            vertices: thirdRegionToInclude
        }]
    }
}, function(err, geofenceGroup) {
    geofenceGroup.isValidKey([0, 0], 'regionA'); // Determines if the point is in any of the whiteout
                                                 // geofences and not in any of the blackout geofences
                                                 // for the the regionA definition
    geofenceGroup.isValidKey([0, 0], 'regionB'); // Ditto for the second region
    geofenceGroup.getValidKeys([0, 0]); // Returns an array of regions the point is in
});

doubleDouble.getGeofenceGroup('groupOfGeofences', function(err, geofenceGroup) {
    console.log('similarly get just by the id if already defined');
    console.log('if the data is provided again, it WILL NOT rebuild all of those geofences');
    console.log('it will use the already-built version, instead, to avoid excessive CPU burn');
});

Installation

npm install double-double-wrapper

Tests

npm test

Contributors

  • David Ellis

FAQs

Package last updated on 06 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts