Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Small, fast, awesome. The only ES5-ish set of polyfills (shims) you can mix-and-match because they're individual AMD modules.

tag: 0.2.1

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 test
Octocat-spinner-32 .gitignore Flattening dir structure for easier package config in both AMD and no… January 24, 2012
Octocat-spinner-32 README.md
Octocat-spinner-32 _base.js
Octocat-spinner-32 array.js
Octocat-spinner-32 function.js
Octocat-spinner-32 object.js
Octocat-spinner-32 poly.js
Octocat-spinner-32 string.js
README.md

Code to modern standards -- or not

version: 0.2.1 License: MIT

poly is a collection of AMD modules that can be used to work with old or new javascript engines in a uniform manner.

Sounds like any other micro-framework, right? Yah, I guess. But poly has some unique features:

  1. poly is a set of AMD modules instead of a monolithic collection of functions
  2. poly will work on just about every javascript-powered browser since IE5.5
  3. poly's modules can be used as either "standardized" abstractions/wrappers or as shims that add methods to native prototypes. You choose.

Examples

Using poly's modules as "standardized" abstractions/wrappers:

// the AMD loader has been configured to point the "array" module id to
// "poly/array". You could later decide not to use poly and switch over to
// another set of modules, such as dojo by aliasing "array" to "dojo/array"

define(/* my module */ ["array"], function (array) {

    // array is a "standardized" wrapper around native array implementations

    return {

        myFunc: function (arr) {

            array.forEach(arr, function (item) {

                console.log(item);

            }

        }

    }

});

Using poly's modules as shims / polyfills:

// somewhere in your app's initialization code, load the "poly/array" module
// using the "poly!" plugin and it will shim the native Array prototype
curl({ preloads: [ "poly!poly/array" ] });

// later, just use arrays as if the js engine supports javascript 1.8!
define(/* my module */ function () {

    // Arrays are so hawt!

    return {

        myFunc: function (arr) {

            arr.forEach(function (item) {

                console.log(item);

            }

        }

    }

});
Something went wrong with that request. Please try again.