diff options
author | Valerio Virgillito | 2012-02-02 00:11:51 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-02 00:11:51 -0800 |
commit | 5a305ec44b2bd5198a248357439aae8ebbd75fee (patch) | |
tree | ec3b756beab7105841353ef79d4e8059b2b6a91c /node_modules/montage/core/shim | |
parent | dbe9c7705860fb3551321e23e7eab763f622241c (diff) | |
download | ninja-5a305ec44b2bd5198a248357439aae8ebbd75fee.tar.gz |
upgrading to Montage v0.6
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/core/shim')
-rw-r--r--[-rwxr-xr-x] | node_modules/montage/core/shim/immediate.js (renamed from node_modules/montage/core/shim/timers.js) | 44 | ||||
-rwxr-xr-x | node_modules/montage/core/shim/structures.js | 22 |
2 files changed, 18 insertions, 48 deletions
diff --git a/node_modules/montage/core/shim/timers.js b/node_modules/montage/core/shim/immediate.js index 859a7aec..3ac48f31 100755..100644 --- a/node_modules/montage/core/shim/timers.js +++ b/node_modules/montage/core/shim/immediate.js | |||
@@ -4,12 +4,13 @@ | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | /** | 7 | /** |
8 | Defines [setImmediate()]{@link setImmediate} and [clearImmediate()]{@link clearImmediate} shim functions. | 8 | [setImmediate()]{@link setImmediate} |
9 | and [clearImmediate()]{@link clearImmediate} shim functions. | ||
9 | @see setImmediate | 10 | @see setImmediate |
10 | @see clearImmediate | 11 | @see clearImmediate |
11 | @module montage/core/shim/timers | 12 | @module montage/core/shim/immediate |
12 | */ | 13 | */ |
13 | 14 | ||
14 | /** | 15 | /** |
15 | @function | 16 | @function |
@@ -25,40 +26,13 @@ | |||
25 | 26 | ||
26 | (function (global) { | 27 | (function (global) { |
27 | 28 | ||
28 | var nextTick; | 29 | var nextTick = require("../next-tick").nextTick; |
29 | if (typeof process !== "undefined") { | ||
30 | nextTick = process.nextTick; | ||
31 | } else if (typeof MessageChannel !== "undefined") { | ||
32 | // http://www.nonblocking.io/2011/06/windownexttick.html | ||
33 | var channel = new MessageChannel(); | ||
34 | // linked list of tasks (single, with head node) | ||
35 | var head = {}, tail = head; | ||
36 | |||
37 | channel.port1.onmessage = function () { | ||
38 | var next = head.next; | ||
39 | var task = next.task; | ||
40 | head = next; | ||
41 | task(); | ||
42 | }; | ||
43 | |||
44 | nextTick = function (task) { | ||
45 | tail = tail.next = {task: task}; | ||
46 | channel.port2.postMessage(void 0); | ||
47 | } | ||
48 | } else if (typeof setTimeout !== "undefined") { | ||
49 | |||
50 | nextTick = function (callback) { | ||
51 | setTimeout(callback, 0); | ||
52 | }; | ||
53 | } else { | ||
54 | throw new Error("Can't shim setImmediate."); | ||
55 | } | ||
56 | 30 | ||
57 | if (typeof setImmediate === "undefined") { | 31 | if (typeof setImmediate === "undefined") { |
32 | |||
58 | var nextHandle = 0; | 33 | var nextHandle = 0; |
59 | var handles = {}; | 34 | var handles = {}; |
60 | 35 | ||
61 | |||
62 | global.setImmediate = function setImmediate(callback) { | 36 | global.setImmediate = function setImmediate(callback) { |
63 | var handle = nextHandle++; | 37 | var handle = nextHandle++; |
64 | var args = arguments.length > 1 ? | 38 | var args = arguments.length > 1 ? |
@@ -77,11 +51,7 @@ if (typeof setImmediate === "undefined") { | |||
77 | global.clearImmediate = function clearImmediate(handle) { | 51 | global.clearImmediate = function clearImmediate(handle) { |
78 | delete handles[handle]; | 52 | delete handles[handle]; |
79 | }; | 53 | }; |
80 | } | ||
81 | 54 | ||
82 | // Make this work as a <script> for bootstrapping montage.js | ||
83 | if (typeof bootstrap !== "undefined") { | ||
84 | bootstrap("core/shim/timers", function () {}); | ||
85 | } | 55 | } |
86 | 56 | ||
87 | })(typeof global === "undefined" ? window : global); | 57 | })(typeof global === "undefined" ? window : global); |
diff --git a/node_modules/montage/core/shim/structures.js b/node_modules/montage/core/shim/structures.js index 2f3d7d05..fb8e2191 100755 --- a/node_modules/montage/core/shim/structures.js +++ b/node_modules/montage/core/shim/structures.js | |||
@@ -17,9 +17,9 @@ | |||
17 | @classdesc Provides a Map data structure for managing key/value pairs, including methods for querying and manipulating map elements. A map cannot contain duplicate keys; each key can map to at most one value. | 17 | @classdesc Provides a Map data structure for managing key/value pairs, including methods for querying and manipulating map elements. A map cannot contain duplicate keys; each key can map to at most one value. |
18 | */ | 18 | */ |
19 | exports.Map = Map; | 19 | exports.Map = Map; |
20 | function Map(ignored, options) { | 20 | function Map(reserved, options) { |
21 | if (!(this instanceof Map)) { | 21 | if (!(this instanceof Map)) { |
22 | return new Map(ignored, options); | 22 | return new Map(reserved, options); |
23 | } | 23 | } |
24 | options = options || {}; | 24 | options = options || {}; |
25 | var eq = options.eq || Set.eq; | 25 | var eq = options.eq || Set.eq; |
@@ -131,9 +131,9 @@ Object.defineProperties(Map.prototype, /** @lends module:montage/core/shim/struc | |||
131 | @class module:montage/core/shim/structures.Set | 131 | @class module:montage/core/shim/structures.Set |
132 | */ | 132 | */ |
133 | exports.Set = Set; | 133 | exports.Set = Set; |
134 | function Set(ignored, options) { | 134 | function Set(reserved, options) { |
135 | if (!(this instanceof Set)) { | 135 | if (!(this instanceof Set)) { |
136 | return new Set(ignored, options); | 136 | return new Set(reserved, options); |
137 | } | 137 | } |
138 | options = options || {}; | 138 | options = options || {}; |
139 | var eq = options.eq || Set.eq; | 139 | var eq = options.eq || Set.eq; |
@@ -238,13 +238,13 @@ Object.defineProperties(Set.prototype, /** @lends module:montage/core/shim/struc | |||
238 | }); | 238 | }); |
239 | /** | 239 | /** |
240 | @class module:montage/core/shim/structures.OrderedSet | 240 | @class module:montage/core/shim/structures.OrderedSet |
241 | @param {boolean} ignored | 241 | @param {boolean} reserved |
242 | @param {object} options | 242 | @param {object} options |
243 | */ | 243 | */ |
244 | exports.OrderedSet = OrderedSet; | 244 | exports.OrderedSet = OrderedSet; |
245 | function OrderedSet(ignored, options) { | 245 | function OrderedSet(reserved, options) { |
246 | if (!(this instanceof OrderedSet)) { | 246 | if (!(this instanceof OrderedSet)) { |
247 | return new OrderedSet(ignored, options); | 247 | return new OrderedSet(reserved, options); |
248 | } | 248 | } |
249 | options = options || {}; | 249 | options = options || {}; |
250 | var eq = options.eq || OrderedSet.eq; | 250 | var eq = options.eq || OrderedSet.eq; |
@@ -397,14 +397,14 @@ Set.hash = function (value) { | |||
397 | /** | 397 | /** |
398 | @exports CacheMap | 398 | @exports CacheMap |
399 | @function | 399 | @function |
400 | @param {Boolean} ignored | 400 | @param {Boolean} reserved |
401 | @param {String} options | 401 | @param {String} options |
402 | @returns new CacheMap(ignored, options) | 402 | @returns new CacheMap(reserved, options) |
403 | */ | 403 | */ |
404 | exports.CacheMap = CacheMap; | 404 | exports.CacheMap = CacheMap; |
405 | function CacheMap(ignored, options) { | 405 | function CacheMap(reserved, options) { |
406 | if (!(this instanceof CacheMap)) { | 406 | if (!(this instanceof CacheMap)) { |
407 | return new CacheMap(ignored, options); | 407 | return new CacheMap(reserved, options); |
408 | } | 408 | } |
409 | options = options || {}; | 409 | options = options || {}; |
410 | 410 | ||