-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-scope.js
47 lines (38 loc) · 1.12 KB
/
no-scope.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @license NoScope v0.1.1
* Copyright (c) 2014 Jonathan Gawrych
* License: MIT
*/
/* jshint evil:true */
(function (window, document, undefined) {
'use strict';
function descriptor(varName) {
return '", {' +
' get: function getter() { return ' + varName + '; }, ' +
' set: function setter(val) { return ' + varName + ' = val; }, ' +
' configurable: true, ' +
' enumerable: true, ' +
'});';
}
window.noScope = function noScope(scopeName, varNames) {
var defineFor = 'Object.defineProperty(' + scopeName + ', "';
var binders = '';
for (var i = 0; i < varNames.length; i++) {
binders += defineFor + varNames[i] + descriptor(varNames[i]);
}
return binders;
};
window.noScope.version = {
full: '0.1.1',
major: 0,
minor: 1,
dot: 1,
codeName: 'unlimited-targets'
};
if (angular) {
// if angular is defined, define an optional module if they rather not use global variables
var NoScope = angular.module('NoScope', []);
NoScope.constant('noScope-version', window.noScope.version);
NoScope.constant('noScope', window.noScope);
}
})(window, document);