Skip to content

Commit 45cd1cd

Browse files
committed
Convert to UMD
1 parent c5a7db6 commit 45cd1cd

File tree

17 files changed

+178
-49
lines changed

17 files changed

+178
-49
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ Code to modern standards. Run everywhere.
33

44
License: MIT
55

6-
poly.js is the a collection of AMD modules that shim (aka "polyfill")
6+
poly.js is the a collection of UMD modules that shim (aka "polyfill")
77
old browsers to support modern (aka "ES5-ish") javascript.
88

99
poly.js is unique amongst ES5-ish shims because it:
1010

1111
* is modular, not monolithic
12-
* is tiny
1312
* is configurable to suit your code
1413
* can be minified using a has-aware optimizer
1514

@@ -22,14 +21,20 @@ Issues: https://github.com/cujojs/poly/issues
2221

2322
Discussion: https://groups.google.com/d/forum/cujojs
2423

24+
Documentation:
25+
26+
* ES5: http://es5.github.io/
27+
* ES6 (draft): http://people.mozilla.org/~jorendorff/es6-draft.html
2528

2629
What's new
2730
---
2831

2932
* 0.6.0
33+
* Converted all modules to UMD (experimental support for node.js!)
3034
* ES6 Array.prototype.find() and Array.prototype.findIndex()
3135
* ES6 Array.from() and Array.of()
3236
* Fix for edge case of Object.getPrototypeOf (thanks Norman Xu!)
37+
* Allow prototype extension for DOM objects in IE8 (thanks Norman Xu and Mikael Karon!)
3338
* 0.5.2
3439
* Implement setImmediate/clearImmediate as a temporary, non-standard method
3540
for performant task queueing.

all.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
* @author Brian Cavalier
66
* @author John Hann
77
*/
8+
(function (define) {
9+
define(function (require) {
810

9-
define(['./object', './string', './date', './array', './function', './json', './xhr', './setImmediate', './array-es6'], function (object, string, date) {
11+
var object = require('./object');
12+
var string = require('./string');
13+
var date = require('./date');
14+
require('./array');
15+
require('./function');
16+
require('./json');
17+
require('./xhr');
18+
require('./setImmediate');
19+
require('./array-es6');
1020

1121
return {
1222
failIfShimmed: object.failIfShimmed,
@@ -15,3 +25,8 @@ define(['./object', './string', './date', './array', './function', './json', './
1525
};
1626

1727
});
28+
}(
29+
typeof define == 'function' && define.amd
30+
? define
31+
: function (factory) { module.exports = factory(require); }
32+
));

array-es6.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
* https://gist.github.com/rwldrn/5079427
1212
* https://gist.github.com/rwldrn/1074126
1313
*/
14-
define(['./lib/_base', './lib/_array'], function (base, array) {
14+
(function (define) {
15+
define(function (require) {
1516
"use strict";
1617

18+
var base = require('./lib/_base');
19+
var array = require('./lib/_array');
20+
1721
var ctor = Array,
1822
proto = ctor.prototype,
1923
slice = proto.slice,
@@ -88,3 +92,8 @@ define(['./lib/_base', './lib/_array'], function (base, array) {
8892
}
8993
}
9094
});
95+
}(
96+
typeof define == 'function' && define.amd
97+
? define
98+
: function (factory) { module.exports = factory(require); }
99+
));

array.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
Array.isArray(object)
3333
3434
*/
35-
36-
define(['./lib/_base', './lib/_array'], function (base, array) {
35+
(function (define) {
36+
define(function (require) {
3737
"use strict";
3838

39+
var base = require('./lib/_base');
40+
var array = require('./lib/_array');
41+
3942
var proto = Array.prototype,
4043
featureMap,
4144
_reduce,
@@ -213,3 +216,8 @@ define(['./lib/_base', './lib/_array'], function (base, array) {
213216
}
214217

215218
});
219+
}(
220+
typeof define == 'function' && define.amd
221+
? define
222+
: function (factory) { module.exports = factory(require); }
223+
));

date.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
*
88
* ES5-ish Date shims for older browsers.
99
*/
10-
(function (origDate) {
11-
define(['./lib/_base'], function (base) {
10+
(function (origDate, define) {
11+
define(function (require) {
12+
13+
var base = require('./lib/_base');
1214

1315
var origProto,
1416
origParse,
@@ -210,4 +212,9 @@ define(['./lib/_base'], function (base) {
210212
};
211213

212214
});
213-
}(Date));
215+
}(
216+
Date,
217+
typeof define == 'function' && define.amd
218+
? define
219+
: function (factory) { module.exports = factory(require); }
220+
));

es5-strict.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
* @author Brian Cavalier
66
* @author John Hann
77
*/
8-
define(['./object', './string', './date', './array', './function', './json', './xhr'], function (object, string, date) {
8+
(function (define) {
9+
define(function (require) {
10+
11+
var object = require('./object');
12+
var string = require('./string');
13+
var date = require('./date');
14+
require('./array');
15+
require('./function');
16+
require('./json');
17+
require('./xhr');
918

1019
var failTestRx;
1120

@@ -27,3 +36,8 @@ define(['./object', './string', './date', './array', './function', './json', './
2736
};
2837

2938
});
39+
}(
40+
typeof define == 'function' && define.amd
41+
? define
42+
: function (factory) { module.exports = factory(require); }
43+
));

es5.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
* @author Brian Cavalier
66
* @author John Hann
77
*/
8-
define(['./object', './string', './date', './array', './function', './json', './xhr'], function (object, string, date) {
8+
(function (define) {
9+
define(function (require) {
10+
11+
var object = require('./object');
12+
var string = require('./string');
13+
var date = require('./date');
14+
require('./array');
15+
require('./function');
16+
require('./json');
17+
require('./xhr');
918

1019
return {
1120
failIfShimmed: object.failIfShimmed,
@@ -14,3 +23,8 @@ define(['./object', './string', './date', './array', './function', './json', './
1423
};
1524

1625
});
26+
}(
27+
typeof define == 'function' && define.amd
28+
? define
29+
: function (factory) { module.exports = factory(require); }
30+
));

function.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
* @author Brian Cavalier
66
* @author John Hann
77
*/
8-
define (['./lib/_base'], function (base) {
8+
(function (define) {
9+
define(function (require) {
910
"use strict";
1011

12+
var base = require('./lib/_base');
13+
1114
var bind,
1215
slice = [].slice,
1316
proto = Function.prototype,
@@ -43,3 +46,8 @@ define (['./lib/_base'], function (base) {
4346
return {};
4447

4548
});
49+
}(
50+
typeof define == 'function' && define.amd
51+
? define
52+
: function (factory) { module.exports = factory(require); }
53+
));

json.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
* @author Brian Cavalier
66
* @author John Hann
77
*/
8-
define(['./support/json3'], function (JSON) {
9-
return JSON;
8+
(function (define) {
9+
define(function (require) {
10+
"use strict";
11+
return require('./support/json3');
1012
});
13+
}(
14+
typeof define == 'function' && define.amd
15+
? define
16+
: function (factory) { module.exports = factory(require); }
17+
));

lib/_array.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
* @author Brian Cavalier
77
* @author John Hann
88
*/
9-
define(['./_base'], function (base) {
9+
(function (define) {
10+
define(function (require) {
11+
12+
var base = require('./_base');
1013

1114
var toObject = base.createCaster(Object, 'Array'),
1215
isFunction = base.isFunction,
@@ -58,6 +61,11 @@ define(['./_base'], function (base) {
5861
}
5962

6063
return true;
61-
};
64+
}
6265

6366
});
67+
}(
68+
typeof define == 'function' && define.amd
69+
? define
70+
: function (factory) { module.exports = factory(require); }
71+
));

0 commit comments

Comments
 (0)