Speedometer: Update the Flight.js implementation to a more recent library version
[WebKit-https.git] / PerformanceTests / Speedometer / resources / todomvc / dependency-examples / flight / flight / node_modules / flight / lib / compose.js
1 /* Copyright 2013 Twitter, Inc. Licensed under The MIT License. http://opensource.org/licenses/MIT */
2
3 define(
4
5   [
6     './utils'
7   ],
8
9   function(utils) {
10     'use strict';
11
12     var dontLock = ['mixedIn', 'attrDef'];
13
14     function setWritability(obj, writable) {
15       Object.keys(obj).forEach(function (key) {
16         if (dontLock.indexOf(key) < 0) {
17           utils.propertyWritability(obj, key, writable);
18         }
19       });
20     }
21
22     function mixin(base, mixins) {
23       base.mixedIn = base.hasOwnProperty('mixedIn') ? base.mixedIn : [];
24
25       for (var i = 0; i < mixins.length; i++) {
26         if (base.mixedIn.indexOf(mixins[i]) == -1) {
27           setWritability(base, false);
28           mixins[i].call(base);
29           base.mixedIn.push(mixins[i]);
30         }
31       }
32
33       setWritability(base, true);
34     }
35
36     return {
37       mixin: mixin
38     };
39
40   }
41 );