Comparing version 1.0.0 to 1.0.1
@@ -0,3 +1,7 @@ | ||
##### 1.0.1 - 17 April 2015 | ||
Fix for improved umd support | ||
##### 1.0.0 - 14 March 2015 | ||
Initial Release |
117
dist/yabh.js
/*! | ||
* yabh | ||
* @version 1.0.0 - Homepage <http://jmdobry.github.io/yabh/> | ||
* @version 1.0.1 - Homepage <http://jmdobry.github.io/yabh/> | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
@@ -14,3 +14,3 @@ * @copyright (c) 2015 Jason Dobry | ||
else if(typeof define === 'function' && define.amd) | ||
define(factory); | ||
define("yabh", factory); | ||
else if(typeof exports === 'object') | ||
@@ -67,6 +67,9 @@ exports["BinaryHeap"] = factory(); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
/** | ||
@@ -104,3 +107,3 @@ * @method bubbleUp | ||
*/ | ||
var bubbleDown = function (heap, weightFunc, n) { | ||
var bubbleDown = function bubbleDown(heap, weightFunc, n) { | ||
var length = heap.length; | ||
@@ -155,7 +158,7 @@ var node = heap[n]; | ||
} | ||
if (typeof weightFunc !== "function") { | ||
throw new Error("BinaryHeap([weightFunc][, compareFunc]): \"weightFunc\" must be a function!"); | ||
if (typeof weightFunc !== 'function') { | ||
throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!'); | ||
} | ||
if (typeof compareFunc !== "function") { | ||
throw new Error("BinaryHeap([weightFunc][, compareFunc]): \"compareFunc\" must be a function!"); | ||
if (typeof compareFunc !== 'function') { | ||
throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!'); | ||
} | ||
@@ -167,54 +170,53 @@ this.weightFunc = weightFunc; | ||
_createClass(BinaryHeap, { | ||
push: { | ||
value: function push(node) { | ||
this.heap.push(node); | ||
bubbleUp(this.heap, this.weightFunc, this.heap.length - 1); | ||
_createClass(BinaryHeap, [{ | ||
key: 'push', | ||
value: function push(node) { | ||
this.heap.push(node); | ||
bubbleUp(this.heap, this.weightFunc, this.heap.length - 1); | ||
} | ||
}, { | ||
key: 'peek', | ||
value: function peek() { | ||
return this.heap[0]; | ||
} | ||
}, { | ||
key: 'pop', | ||
value: function pop() { | ||
var front = this.heap[0]; | ||
var end = this.heap.pop(); | ||
if (this.heap.length > 0) { | ||
this.heap[0] = end; | ||
bubbleDown(this.heap, this.weightFunc, 0); | ||
} | ||
}, | ||
peek: { | ||
value: function peek() { | ||
return this.heap[0]; | ||
} | ||
}, | ||
pop: { | ||
value: function pop() { | ||
var front = this.heap[0]; | ||
var end = this.heap.pop(); | ||
if (this.heap.length > 0) { | ||
this.heap[0] = end; | ||
bubbleDown(this.heap, this.weightFunc, 0); | ||
} | ||
return front; | ||
} | ||
}, | ||
remove: { | ||
value: function remove(node) { | ||
var length = this.heap.length; | ||
for (var i = 0; i < length; i++) { | ||
if (this.compareFunc(this.heap[i], node)) { | ||
var removed = this.heap[i]; | ||
var end = this.heap.pop(); | ||
if (i !== length - 1) { | ||
this.heap[i] = end; | ||
bubbleUp(this.heap, this.weightFunc, i); | ||
bubbleDown(this.heap, this.weightFunc, i); | ||
} | ||
return removed; | ||
return front; | ||
} | ||
}, { | ||
key: 'remove', | ||
value: function remove(node) { | ||
var length = this.heap.length; | ||
for (var i = 0; i < length; i++) { | ||
if (this.compareFunc(this.heap[i], node)) { | ||
var removed = this.heap[i]; | ||
var end = this.heap.pop(); | ||
if (i !== length - 1) { | ||
this.heap[i] = end; | ||
bubbleUp(this.heap, this.weightFunc, i); | ||
bubbleDown(this.heap, this.weightFunc, i); | ||
} | ||
return removed; | ||
} | ||
return null; | ||
} | ||
}, | ||
removeAll: { | ||
value: function removeAll() { | ||
this.heap = []; | ||
} | ||
}, | ||
size: { | ||
value: function size() { | ||
return this.heap.length; | ||
} | ||
return null; | ||
} | ||
}); | ||
}, { | ||
key: 'removeAll', | ||
value: function removeAll() { | ||
this.heap = []; | ||
} | ||
}, { | ||
key: 'size', | ||
value: function size() { | ||
return this.heap.length; | ||
} | ||
}]); | ||
@@ -224,3 +226,4 @@ return BinaryHeap; | ||
module.exports = BinaryHeap; | ||
exports['default'] = BinaryHeap; | ||
module.exports = exports['default']; | ||
@@ -227,0 +230,0 @@ /***/ } |
/** | ||
* @author Jason Dobry <jason.dobry@gmail.com> | ||
* @file yabh.min.js | ||
* @version 1.0.0 - Homepage <http://jmdobry.github.io/yabh/> | ||
* @version 1.0.1 - Homepage <http://jmdobry.github.io/yabh/> | ||
* @copyright (c) 2015 Jason Dobry | ||
@@ -11,3 +11,3 @@ * @license MIT <https://github.com/jmdobry/yabh/blob/master/LICENSE> | ||
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):"object"==typeof exports?exports.BinaryHeap=b():a.BinaryHeap=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a){function b(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}var c=function(){function a(a,b){for(var c in b){var d=b[c];d.configurable=!0,d.value&&(d.writable=!0)}Object.defineProperties(a,b)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),d=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},e=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},f=function(){function a(b,c){if(d(this,a),b||(b=function(a){return a}),c||(c=function(a,b){return a===b}),"function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof c)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=b,this.compareFunc=c,this.heap=[]}return c(a,{push:{value:function(a){this.heap.push(a),b(this.heap,this.weightFunc,this.heap.length-1)}},peek:{value:function(){return this.heap[0]}},pop:{value:function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,e(this.heap,this.weightFunc,0)),a}},remove:{value:function(a){for(var c=this.heap.length,d=0;c>d;d++)if(this.compareFunc(this.heap[d],a)){var f=this.heap[d],g=this.heap.pop();return d!==c-1&&(this.heap[d]=g,b(this.heap,this.weightFunc,d),e(this.heap,this.weightFunc,d)),f}return null}},removeAll:{value:function(){this.heap=[]}},size:{value:function(){return this.heap.length}}}),a}();a.exports=f}])}); | ||
!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define("yabh",b):"object"==typeof exports?exports.BinaryHeap=b():a.BinaryHeap=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){function d(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}var e=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(b,"__esModule",{value:!0});var g=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},h=function(){function a(b,c){if(e(this,a),b||(b=function(a){return a}),c||(c=function(a,b){return a===b}),"function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof c)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=b,this.compareFunc=c,this.heap=[]}return f(a,[{key:"push",value:function(a){this.heap.push(a),d(this.heap,this.weightFunc,this.heap.length-1)}},{key:"peek",value:function(){return this.heap[0]}},{key:"pop",value:function(){var a=this.heap[0],b=this.heap.pop();return this.heap.length>0&&(this.heap[0]=b,g(this.heap,this.weightFunc,0)),a}},{key:"remove",value:function(a){for(var b=this.heap.length,c=0;b>c;c++)if(this.compareFunc(this.heap[c],a)){var e=this.heap[c],f=this.heap.pop();return c!==b-1&&(this.heap[c]=f,d(this.heap,this.weightFunc,c),g(this.heap,this.weightFunc,c)),e}return null}},{key:"removeAll",value:function(){this.heap=[]}},{key:"size",value:function(){return this.heap.length}}]),a}();b["default"]=h,a.exports=b["default"]}])}); | ||
//# sourceMappingURL=yabh.min.map |
@@ -65,5 +65,2 @@ /* | ||
module: { | ||
loaders: [ | ||
{ test: /(src)(.+)\.js$/, exclude: /node_modules/, loader: 'babel-loader?blacklist=useStrict' } | ||
], | ||
preLoaders: [ | ||
@@ -75,5 +72,24 @@ { | ||
} | ||
], | ||
loaders: [ | ||
{ test: /(src)(.+)\.js$/, exclude: /node_modules/, loader: 'babel-loader?blacklist=useStrict' } | ||
] | ||
}, | ||
plugins: [ | ||
{ | ||
apply: function (compiler) { | ||
compiler.plugin('compilation', function (compilation) { | ||
compilation.plugin('optimize-chunk-assets', function (chunks, callback) { | ||
chunks.forEach(function (chunk) { | ||
if (chunk.initial) { | ||
chunk.files.forEach(function (file) { | ||
compilation.assets[file].children[0].children[0]._value = compilation.assets[file].children[0].children[0]._value.replace('define(factory)', 'define("yabh", factory)'); | ||
}); | ||
} | ||
}); | ||
callback(); | ||
}); | ||
}); | ||
} | ||
}, | ||
new webpack.BannerPlugin(banner) | ||
@@ -80,0 +96,0 @@ ] |
{ | ||
"name": "yabh", | ||
"description": "Yet another Binary Heap.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"homepage": "http://jmdobry.github.io/yabh/", | ||
@@ -29,7 +29,7 @@ "repository": { | ||
"devDependencies": { | ||
"babel-core": "4.7.12", | ||
"babel-loader": "4.1.0", | ||
"babel-core": "5.1.10", | ||
"babel-loader": "5.0.0", | ||
"grunt": "0.4.5", | ||
"grunt-contrib-clean": "0.6.0", | ||
"grunt-contrib-uglify": "0.8.0", | ||
"grunt-contrib-uglify": "0.9.1", | ||
"grunt-karma": "0.10.1", | ||
@@ -40,8 +40,8 @@ "grunt-karma-coveralls": "2.5.3", | ||
"jit-grunt": "0.9.1", | ||
"jshint": "2.6.3", | ||
"jshint": "2.7.0", | ||
"jshint-loader": "0.8.3", | ||
"karma": "0.12.31", | ||
"karma-chai": "0.1.0", | ||
"karma-chrome-launcher": "0.1.7", | ||
"karma-coverage": "0.2.7", | ||
"karma-chrome-launcher": "0.1.8", | ||
"karma-coverage": "0.3.1", | ||
"karma-firefox-launcher": "0.1.4", | ||
@@ -51,5 +51,5 @@ "karma-mocha": "0.1.10", | ||
"karma-script-launcher": "0.1.0", | ||
"karma-spec-reporter": "0.0.16", | ||
"time-grunt": "1.1.0", | ||
"webpack-dev-server": "1.7.0" | ||
"karma-spec-reporter": "0.0.19", | ||
"time-grunt": "1.1.1", | ||
"webpack-dev-server": "1.8.0" | ||
}, | ||
@@ -56,0 +56,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
46838
966