Giter VIP home page Giter VIP logo

pixel's Introduction

pixel

Simple "pixel" library for component, inspired heavily by superagent.

Installation

$ component install redventures/pixel

API

.pixel(type)

Instantitates a new pixel for the given type. The supported types are:

  • image
  • script
var pixel = require('pixel');

pixel('image')
  .send({ key1: 'value1' })
  .send({ key2: 'value2' })
  .end();

pixel('script')
  .send('key1', 'value1')
  .send('key2', 'value2')
  .end(function(){
    // optional callback
  });

.send(key, value)

Appends key=value as a querystring parameter of the pixel request. Note that this will urlencode the values for you.

pixel('image')
  .send('key1', 'value 1')
  .send({ key2: 'value 2' })
  .send({ 
    key3: 'value 3',
    key4: 'value 4'
  })
  .end();

.set(key, value)

Sets the configuration value for the request. If you want to change it for all requests, see .defaults().

pixel('script')
  .set('host', 'foo.com')
  .set('path', '/bar.js')
  .send('key', 'value')
  .end();

.end([callback])

Sends the actual HTTP request for the pixel, invoking the optional callback.

pixel.defaults(options)

Sets the defaults for every pixel instantiated. The options and predefined defaults are:

  • host: Remote hostname. Defaults to location.hostname.
  • path: Remote path. Defaults to /pixel.
  • protocol: Remote protocol. Defaults to location.protocol
  • cacheBust: Whether to append a random "cache bust" to the URL.
var pixel = require('pixel');

pixel.defaults({
  host: '//google.com',
  path: '/api'
});

pixel('script')
  .send('key', 'value')
  .end();

TODO

  • more tests, specially IE and mobile.
  • passing responses back to .end(callback). Probably only for script type.

License

Copyright 2012 Red Ventures

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

pixel's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ghas-results

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.