typescript-dotnet-amd
Version:
A JavaScript-Friendly .NET Based TypeScript Library.
6 lines • 3.79 kB
JavaScript
/*!
* @author electricessence / https://github.com/electricessence/
* Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
*/
define(["require","exports","../../Types","../../Integer","../../Compare","../../Exceptions/ArgumentException","../../Exceptions/ArgumentNullException","../../Exceptions/ArgumentOutOfRangeException","./initialize","./copy"],function(e,n,t,r,i,o,a,u,f,c){"use strict";function l(e,n,r){void 0===r&&(r=i.areEqual);var o=e&&e.length;if(o){if(r==i.areEqual&&e instanceof Array&&!t.Type.isTrueNaN(n))return e.indexOf(n);for(var a=0;a<o;a++)if(r(e[a],n))return a}return-1}function s(e,n,t){return void 0===t&&(t=i.areEqual),l(e,n,t)!=-1}function g(e,n,t,r){if(void 0===r&&(r=1/0),!e||!e.length||0===r)return 0;if(r<0)throw new u.ArgumentOutOfRangeException("max",r,z);r||(r=1/0);for(var i=0,o=0,a=e.length;o<a&&(e[o]!==n||(e[o]=t,++i,i!=r));o++);return i}function p(e,n,t,i){if(void 0===t&&(t=0),e){if(r.Integer.assertZeroOrGreater(t,"start"),i||0===i||(i=e.length),r.Integer.assert(i,"stop"),i<t)throw new u.ArgumentOutOfRangeException("stop",i,"is less than start");for(var o=t;o<i;o++)e[o]=n}}function v(e,n,t){void 0===n&&(n=0),p(e,null,n,t)}function h(e,n,t){if(void 0===t&&(t=i.areEqual),!e)throw new a.ArgumentNullException("array",b);var r=e.length,o=!r||!s(e,n,t);return o&&(e[r]=n),o}function x(e,n){if(!e)throw new a.ArgumentNullException("array",b);if(!t.Type.isFunction(n))throw new o.ArgumentException("predicate","Must be a function.");var r=e.length;if(!t.Type.isNumber(r,!0)||r<0)throw new o.ArgumentException("array","Does not have a valid length.");if(e instanceof Array){for(var i=0;i<r;i++)if(n(e[i],i))return i}else for(var i=0;i<r;i++)if(i in e&&n(e[i],i))return i;return-1}function w(e,n){if(e&&n)for(var t=0;t<e.length&&n(e[t],t)!==!1;t++);}function d(e,n){if(e&&n)for(var t=0;t<e.length;t++)e[t]=n(e[t],t)}function E(e,n){if(!e)throw new a.ArgumentNullException("array",b);if(r.Integer.assert(n,"index"),n<0)throw new u.ArgumentOutOfRangeException("index",n,z);var t=n<e.length;return t&&e.splice(n,1),t}function m(e,n,t,r){if(void 0===t&&(t=1/0),void 0===r&&(r=i.areEqual),!e||!e.length||0===t)return 0;if(t<0)throw new u.ArgumentOutOfRangeException("max",t,z);var o=0;if(t&&isFinite(t)){for(var a=[],f=0,c=e.length;f<c&&(!r(e[f],n)||(a.push(f),++o,o!=t));f++);for(var f=a.length-1;f>=0;f--)e.splice(a[f],1)}else for(var f=e.length-1;f>=0;f--)r(e[f],n)&&(e.splice(f,1),++o);return o}function O(e,n){if(r.Integer.assert(n,"count"),n<0)throw new u.ArgumentOutOfRangeException("count",n,z);for(var t=f.initialize(n),i=0;i<n;i++)t[i]=e;return t}function A(e,n,t){if(void 0===t&&(t=1),isNaN(e)||!isFinite(e))throw new u.ArgumentOutOfRangeException("first",e,I);if(isNaN(n)||!isFinite(n))throw new u.ArgumentOutOfRangeException("count",n,I);if(n<0)throw new u.ArgumentOutOfRangeException("count",n,z);for(var r=f.initialize(n),i=0;i<n;i++)r[i]=e,e+=t;return r}function y(e,n,t){if(void 0===t&&(t=1),0==t)throw new u.ArgumentOutOfRangeException("step",t,T);return A(e,(n-e)/t,t)}function N(e){if(!e)return[];var n={};return e.filter(function(e){return!(e in n)&&(n[e]=!0)})}function R(e,n){void 0===n&&(n=0);for(var t=[],r=0;r<e.length;r++){var i=e[r];if(i instanceof Array){n>0&&(i=R(i,n-1));for(var o=0;o<i.length;o++)t.push(i[o])}else t.push(i)}return t}Object.defineProperty(n,"__esModule",{value:!0}),n.initialize=f.initialize,n.copy=c.copy,n.copyTo=c.copyTo;var b="Cannot be null.",T="Cannot be zero.",z="Cannot be less than zero.",I="Must be a valid finite number";n.indexOf=l,n.contains=s,n.replace=g,n.updateRange=p,n.clear=v,n.register=h,n.findIndex=x,n.forEach=w,n.applyTo=d,n.removeIndex=E,n.remove=m,n.repeat=O,n.range=A,n.rangeUntil=y,n.distinct=N,n.flatten=R});
//# sourceMappingURL=Utility.js.map