Global Targeting Types for Node.js
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.editorconfig
.eslintrc
.gitignore
.nvmrc
.nycrc
.travis.yml
README.md
package.json

README.md

isocket-targeting Build Status NPM version

Global Targeting Types for Node.js provides easy access to common ad targeting types based on the isocket API

Install

npm install isocket-targeting --save

Usage

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

  1. Given a targeting UID returns a targeting
  2. Given a list of targeting UIDs returns a list of targetings
  3. 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