decova-dotnet
Version:
This package provides fundumentals that a .net developer may miss while working with Typescript, whether they are missing functinalities or funcionalities provided in a non-elegant design in javascript. Bad naming, bad design of optional parameters, non-c
131 lines • 4.15 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./Array.types");
require("./ReadonlyArray");
const List_1 = require("./List");
const __1 = require("..");
let proto = Array.prototype;
proto.xCount = function () {
return this.length;
};
proto.xSelect = function (mapper) {
return new List_1.List(this).Select(mapper).Array;
};
proto.xSelectMany = function (func) {
return new List_1.List(this).SelectMany(func).Array;
};
proto.xSort = function (compareFn) {
return new List_1.List(this).Sort(compareFn).Array;
};
proto.xReverse = function () {
return new List_1.List(this).Array;
};
proto.xForeach = function (func) {
new List_1.List(this).Foreach(i => func(i));
};
proto.xAny = function (func) {
return new List_1.List(this).Any(func);
};
proto.xAll = function (func) {
return new List_1.List(this).All(func);
};
proto.xIsEmpty = function () {
return this.length == 0;
};
proto.xAdd = function (item) {
this.push(item);
};
proto.xEnsureItem = function (item, comparer) {
const lst = new List_1.List(this);
return lst.EnsureItem(item, comparer);
};
proto.xAddRange = function (items) {
new List_1.List(this).AddRange(items);
};
proto.xUnion = function (another) {
return new List_1.List(this).Union(another).Array;
};
proto.xWhere = function (func) {
return new List_1.List(this).Where(func).Array;
};
proto.xItemAt = function (index) {
return new List_1.List(this).ItemAt(index);
};
proto.xIndexOf = function (item) {
return new List_1.List(this).IndexOf(item);
};
proto.xRemoveAt = function (index) {
new List_1.List(this).RemoveAt(index);
};
proto.xOfType = function (type) {
return this.xWhere((i) => __1.TypeInfo.of(type).isAssignableFrom(__1.TypeInfo.ofObject(i)));
};
proto.xRemoveRange = function (index, lenght) {
const output = new List_1.List(this).RemoveRange(index, lenght);
return output;
};
proto.xRemoveWhere = function (func) {
const output = new List_1.List(this).RemoveWhere(func);
return output;
};
proto.xGetRange = function (index, length = undefined) {
return new List_1.List(this).GetRange(index, length).Array;
};
proto.xInsert = function (index, item) {
new List_1.List(this).Insert(index, item);
};
proto.xInsertRange = function (index, items) {
new List_1.List(this).InsertRange(index, items);
};
proto.xFirstOrNull = function (func) {
return new List_1.List(this).FirstOrNull(func);
};
proto.xFirst = function (func) {
return new List_1.List(this).First(func);
};
proto.xLastOrNull = function (func) {
return new List_1.List(this).LastOrNull(func);
};
proto.xLast = function (func) {
return new List_1.List(this).Last(func);
};
proto.xSkip = function (countToSkip) {
return new List_1.List(this).Skip(countToSkip).Array;
};
proto.xTake = function (countToTake) {
return new List_1.List(this).Array;
};
proto.xContains = function (obj) {
return new List_1.List(this).Contains(obj);
};
proto.xDistinct = function () {
return new List_1.List(this).Distinct().Array;
};
proto.xExcept = function (except) {
return new List_1.List(this).Except(except).Array;
};
proto.xClone = function () {
return new List_1.List(this).Array;
};
proto.xIntersect = function (otherArray) {
return new List_1.List(this).Intersect(otherArray).Array;
};
proto.xToMap = function (keySelector, distinctItems = false) {
return new List_1.List(this).ToMap(keySelector, distinctItems);
};
proto.xReset = function () {
new List_1.List(this).Reset();
};
proto.xRemoveWhere = function (selector) {
const output = new List_1.List(this).RemoveWhere(selector);
return output;
};
proto.xEnsureItem = function (item, comparer) {
const lst = new List_1.List(this);
return lst.EnsureItem(item, comparer);
};
proto.xOfType = function (type) {
const lst = new List_1.List(this);
return lst.Where(item => !item && __1.TypeInfo.of(type).isAssignableFrom(item.constructor)).Array;
};
//# sourceMappingURL=Array.impl.js.map