isocket-targeting
v1.0.0
Published
isocket-targeting [](https://travis-ci.org/isocket/isocket-targeting) [](http://badge.fury.io/js/isocket-targeting) =========
Readme
isocket-targeting

Global Targeting Types for Node.js provides easy access to common ad targeting types based on the isocket API
Install
npm install isocket-targeting --saveUsage
const Targeting = require('isocket-targeting')
Targeting.sync((err) => {
if (err) throw err
Targeting.findByUid('T-GEO_US', (err, targeting) => {
if (err) throw err
console.log(targeting.name) // => United States
})
})API
sync
Loads data synchronously. Mostly provided as backwards compatibility with pre-v1. Optionally takes a callback argument.
Targeting.sync()getType
Given a type of geo or fcap returns list of targetings
Targeting.getType('fcap', (err, targetings) => {
assert.ok(targetings.length)
})findAllByType
Alias of getType
findByUid
- Given a targeting UID returns a targeting
- Given a list of targeting UIDs returns a list of targetings
- If no targetings are found returns
null
Targeting.findByUid('T-GEO_US', (err, targeting) => {
assert.equal(targeting.name, 'United States')
})getGeoTree
Returns a tree of root -> countries -> DMAs. Each child is a targeting.
Targeting.getGeoTree((err, tree) => {
assert.ok(tree.hasOwnProperty('children'))
assert.ok(tree.children.length)
})Test
npm test