-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1283 from kbase/sorta-genome-browser-widget
pulling the trigger
- Loading branch information
Showing
957 changed files
with
25,864 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@root | ||
|
||
module | ||
|
||
tabs | ||
indent 2 | ||
maxlen 100 | ||
|
||
ass | ||
nomen | ||
plusplus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
/node_modules | ||
/npm-debug.log | ||
/.lintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
language: node_js | ||
node_js: | ||
- 0.12 | ||
- 4 | ||
- 5 | ||
|
||
before_install: | ||
- mkdir node_modules; ln -s ../ node_modules/d | ||
|
||
notifications: | ||
email: | ||
- medikoo+d@medikoo.com | ||
|
||
script: "npm test && npm run lint" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
v1.0.0 -- 2015.12.04 | ||
- autoBind changes: | ||
- replace `bindTo` argument with options and `resolveContext` option | ||
- Add support `overwriteDefinition` | ||
- Introduce IE11 bug workaround in `lazy` handler | ||
|
||
v0.1.1 -- 2014.04.24 | ||
- Add `autoBind` and `lazy` utilities | ||
- Allow to pass other options to be merged onto created descriptor. | ||
Useful when used with other custom utilties | ||
|
||
v0.1.0 -- 2013.06.20 | ||
Initial (derived from es5-ext project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# D | ||
## Property descriptor factory | ||
|
||
_Originally derived from [es5-ext](https://github.com/medikoo/es5-ext) package._ | ||
|
||
Defining properties with descriptors is very verbose: | ||
|
||
```javascript | ||
var Account = function () {}; | ||
Object.defineProperties(Account.prototype, { | ||
deposit: { value: function () { | ||
/* ... */ | ||
}, configurable: true, enumerable: false, writable: true }, | ||
withdraw: { value: function () { | ||
/* ... */ | ||
}, configurable: true, enumerable: false, writable: true }, | ||
balance: { get: function () { | ||
/* ... */ | ||
}, configurable: true, enumerable: false } | ||
}); | ||
``` | ||
|
||
D cuts that to: | ||
|
||
```javascript | ||
var d = require('d'); | ||
|
||
var Account = function () {}; | ||
Object.defineProperties(Account.prototype, { | ||
deposit: d(function () { | ||
/* ... */ | ||
}), | ||
withdraw: d(function () { | ||
/* ... */ | ||
}), | ||
balance: d.gs(function () { | ||
/* ... */ | ||
}) | ||
}); | ||
``` | ||
|
||
By default, created descriptor follow characteristics of native ES5 properties, and defines values as: | ||
|
||
```javascript | ||
{ configurable: true, enumerable: false, writable: true } | ||
``` | ||
|
||
You can overwrite it by preceding _value_ argument with instruction: | ||
```javascript | ||
d('c', value); // { configurable: true, enumerable: false, writable: false } | ||
d('ce', value); // { configurable: true, enumerable: true, writable: false } | ||
d('e', value); // { configurable: false, enumerable: true, writable: false } | ||
|
||
// Same way for get/set: | ||
d.gs('e', value); // { configurable: false, enumerable: true } | ||
``` | ||
|
||
### Installation | ||
|
||
$ npm install d | ||
|
||
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) | ||
|
||
### Other utilities | ||
|
||
#### autoBind(obj, props) _(d/auto-bind)_ | ||
|
||
Define methods which will be automatically bound to its instances | ||
|
||
```javascript | ||
var d = require('d'); | ||
var autoBind = require('d/auto-bind'); | ||
|
||
var Foo = function () { this._count = 0; }; | ||
Object.defineProperties(Foo.prototype, autoBind({ | ||
increment: d(function () { ++this._count; }); | ||
})); | ||
|
||
var foo = new Foo(); | ||
|
||
// Increment foo counter on each domEl click | ||
domEl.addEventListener('click', foo.increment, false); | ||
``` | ||
|
||
#### lazy(obj, props) _(d/lazy)_ | ||
|
||
Define lazy properties, which will be resolved on first access | ||
|
||
```javascript | ||
var d = require('d'); | ||
var lazy = require('d/lazy'); | ||
|
||
var Foo = function () {}; | ||
Object.defineProperties(Foo.prototype, lazy({ | ||
items: d(function () { return []; }) | ||
})); | ||
|
||
var foo = new Foo(); | ||
foo.items.push(1, 2); // foo.items array created and defined directly on foo | ||
``` | ||
|
||
## Tests [![Build Status](https://travis-ci.org/medikoo/d.png)](https://travis-ci.org/medikoo/d) | ||
|
||
$ npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
var copy = require('es5-ext/object/copy') | ||
, normalizeOptions = require('es5-ext/object/normalize-options') | ||
, ensureCallable = require('es5-ext/object/valid-callable') | ||
, map = require('es5-ext/object/map') | ||
, callable = require('es5-ext/object/valid-callable') | ||
, validValue = require('es5-ext/object/valid-value') | ||
|
||
, bind = Function.prototype.bind, defineProperty = Object.defineProperty | ||
, hasOwnProperty = Object.prototype.hasOwnProperty | ||
, define; | ||
|
||
define = function (name, desc, options) { | ||
var value = validValue(desc) && callable(desc.value), dgs; | ||
dgs = copy(desc); | ||
delete dgs.writable; | ||
delete dgs.value; | ||
dgs.get = function () { | ||
if (!options.overwriteDefinition && hasOwnProperty.call(this, name)) return value; | ||
desc.value = bind.call(value, options.resolveContext ? options.resolveContext(this) : this); | ||
defineProperty(this, name, desc); | ||
return this[name]; | ||
}; | ||
return dgs; | ||
}; | ||
|
||
module.exports = function (props/*, options*/) { | ||
var options = normalizeOptions(arguments[1]); | ||
if (options.resolveContext != null) ensureCallable(options.resolveContext); | ||
return map(props, function (desc, name) { return define(name, desc, options); }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
|
||
var assign = require('es5-ext/object/assign') | ||
, normalizeOpts = require('es5-ext/object/normalize-options') | ||
, isCallable = require('es5-ext/object/is-callable') | ||
, contains = require('es5-ext/string/#/contains') | ||
|
||
, d; | ||
|
||
d = module.exports = function (dscr, value/*, options*/) { | ||
var c, e, w, options, desc; | ||
if ((arguments.length < 2) || (typeof dscr !== 'string')) { | ||
options = value; | ||
value = dscr; | ||
dscr = null; | ||
} else { | ||
options = arguments[2]; | ||
} | ||
if (dscr == null) { | ||
c = w = true; | ||
e = false; | ||
} else { | ||
c = contains.call(dscr, 'c'); | ||
e = contains.call(dscr, 'e'); | ||
w = contains.call(dscr, 'w'); | ||
} | ||
|
||
desc = { value: value, configurable: c, enumerable: e, writable: w }; | ||
return !options ? desc : assign(normalizeOpts(options), desc); | ||
}; | ||
|
||
d.gs = function (dscr, get, set/*, options*/) { | ||
var c, e, options, desc; | ||
if (typeof dscr !== 'string') { | ||
options = set; | ||
set = get; | ||
get = dscr; | ||
dscr = null; | ||
} else { | ||
options = arguments[3]; | ||
} | ||
if (get == null) { | ||
get = undefined; | ||
} else if (!isCallable(get)) { | ||
options = get; | ||
get = set = undefined; | ||
} else if (set == null) { | ||
set = undefined; | ||
} else if (!isCallable(set)) { | ||
options = set; | ||
set = undefined; | ||
} | ||
if (dscr == null) { | ||
c = true; | ||
e = false; | ||
} else { | ||
c = contains.call(dscr, 'c'); | ||
e = contains.call(dscr, 'e'); | ||
} | ||
|
||
desc = { get: get, set: set, configurable: c, enumerable: e }; | ||
return !options ? desc : assign(normalizeOpts(options), desc); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
'use strict'; | ||
|
||
var map = require('es5-ext/object/map') | ||
, isCallable = require('es5-ext/object/is-callable') | ||
, validValue = require('es5-ext/object/valid-value') | ||
, contains = require('es5-ext/string/#/contains') | ||
|
||
, call = Function.prototype.call | ||
, defineProperty = Object.defineProperty | ||
, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor | ||
, getPrototypeOf = Object.getPrototypeOf | ||
, hasOwnProperty = Object.prototype.hasOwnProperty | ||
, cacheDesc = { configurable: false, enumerable: false, writable: false, | ||
value: null } | ||
, define; | ||
|
||
define = function (name, options) { | ||
var value, dgs, cacheName, desc, writable = false, resolvable | ||
, flat; | ||
options = Object(validValue(options)); | ||
cacheName = options.cacheName; | ||
flat = options.flat; | ||
if (cacheName == null) cacheName = name; | ||
delete options.cacheName; | ||
value = options.value; | ||
resolvable = isCallable(value); | ||
delete options.value; | ||
dgs = { configurable: Boolean(options.configurable), | ||
enumerable: Boolean(options.enumerable) }; | ||
if (name !== cacheName) { | ||
dgs.get = function () { | ||
if (hasOwnProperty.call(this, cacheName)) return this[cacheName]; | ||
cacheDesc.value = resolvable ? call.call(value, this, options) : value; | ||
cacheDesc.writable = writable; | ||
defineProperty(this, cacheName, cacheDesc); | ||
cacheDesc.value = null; | ||
if (desc) defineProperty(this, name, desc); | ||
return this[cacheName]; | ||
}; | ||
} else if (!flat) { | ||
dgs.get = function self() { | ||
var ownDesc; | ||
if (hasOwnProperty.call(this, name)) { | ||
ownDesc = getOwnPropertyDescriptor(this, name); | ||
// It happens in Safari, that getter is still called after property | ||
// was defined with a value, following workarounds that | ||
// While in IE11 it may happen that here ownDesc is undefined (go figure) | ||
if (ownDesc) { | ||
if (ownDesc.hasOwnProperty('value')) return ownDesc.value; | ||
if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { | ||
return ownDesc.get.call(this); | ||
} | ||
return value; | ||
} | ||
} | ||
desc.value = resolvable ? call.call(value, this, options) : value; | ||
defineProperty(this, name, desc); | ||
desc.value = null; | ||
return this[name]; | ||
}; | ||
} else { | ||
dgs.get = function self() { | ||
var base = this, ownDesc; | ||
if (hasOwnProperty.call(this, name)) { | ||
// It happens in Safari, that getter is still called after property | ||
// was defined with a value, following workarounds that | ||
ownDesc = getOwnPropertyDescriptor(this, name); | ||
if (ownDesc.hasOwnProperty('value')) return ownDesc.value; | ||
if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { | ||
return ownDesc.get.call(this); | ||
} | ||
} | ||
while (!hasOwnProperty.call(base, name)) base = getPrototypeOf(base); | ||
desc.value = resolvable ? call.call(value, base, options) : value; | ||
defineProperty(base, name, desc); | ||
desc.value = null; | ||
return base[name]; | ||
}; | ||
} | ||
dgs.set = function (value) { | ||
if (hasOwnProperty.call(this, name)) { | ||
throw new TypeError("Cannot assign to lazy defined '" + name + "' property of " + this); | ||
} | ||
dgs.get.call(this); | ||
this[cacheName] = value; | ||
}; | ||
if (options.desc) { | ||
desc = { | ||
configurable: contains.call(options.desc, 'c'), | ||
enumerable: contains.call(options.desc, 'e') | ||
}; | ||
if (cacheName === name) { | ||
desc.writable = contains.call(options.desc, 'w'); | ||
desc.value = null; | ||
} else { | ||
writable = contains.call(options.desc, 'w'); | ||
desc.get = dgs.get; | ||
desc.set = dgs.set; | ||
} | ||
delete options.desc; | ||
} else if (cacheName === name) { | ||
desc = { | ||
configurable: Boolean(options.configurable), | ||
enumerable: Boolean(options.enumerable), | ||
writable: Boolean(options.writable), | ||
value: null | ||
}; | ||
} | ||
delete options.configurable; | ||
delete options.enumerable; | ||
delete options.writable; | ||
return dgs; | ||
}; | ||
|
||
module.exports = function (props) { | ||
return map(props, function (desc, name) { return define(name, desc); }); | ||
}; |
Oops, something went wrong.