@simplism/core
Advanced tools
Comparing version 6.0.51 to 6.0.52
interface Array<T> { | ||
mapMany<R>(predicate: (item: T, index: number) => R[]): R[]; | ||
last(predicate?: (item: T, index: number) => boolean): T | undefined; | ||
} |
@@ -7,2 +7,3 @@ import "./extensions/ArrayExtensions"; | ||
export * from "./types/Type"; | ||
export * from "./types/Uuid"; | ||
export * from "./utils/Logger"; |
@@ -208,2 +208,14 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
}; | ||
Array.prototype.last = function (predicate) { | ||
if (predicate) { | ||
for (var i = this.length - 1; i >= 0; i--) { | ||
if (predicate(this[i], i)) { | ||
return this[i]; | ||
} | ||
} | ||
} | ||
else { | ||
return this[this.length - 1]; | ||
} | ||
}; | ||
@@ -232,2 +244,3 @@ | ||
__export(__webpack_require__(/*! ./types/Type */ "./packages/core/src/types/Type.ts")); | ||
__export(__webpack_require__(/*! ./types/Uuid */ "./packages/core/src/types/Uuid.ts")); | ||
__export(__webpack_require__(/*! ./utils/Logger */ "./packages/core/src/utils/Logger.ts")); | ||
@@ -368,2 +381,30 @@ | ||
/***/ "./packages/core/src/types/Uuid.ts": | ||
/*!*****************************************!*\ | ||
!*** ./packages/core/src/types/Uuid.ts ***! | ||
\*****************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Uuid = (function () { | ||
function Uuid() { | ||
this._uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { | ||
var r = Math.random() * 16 | 0; | ||
var v = c === "x" ? r : (r & 0x3 | 0x8); | ||
return v.toString(16); | ||
}); | ||
} | ||
Uuid.prototype.toString = function () { | ||
return this._uuid; | ||
}; | ||
return Uuid; | ||
}()); | ||
exports.Uuid = Uuid; | ||
/***/ }), | ||
/***/ "./packages/core/src/utils/Logger.ts": | ||
@@ -370,0 +411,0 @@ /*!*******************************************!*\ |
{ | ||
"name": "@simplism/core", | ||
"version": "6.0.51", | ||
"version": "6.0.52", | ||
"description": "Simplism Core Package", | ||
@@ -5,0 +5,0 @@ "repository": "github:kslhunter/simplism6", |
declare interface Array<T> { | ||
mapMany<R>(predicate: (item: T, index: number) => R[]): R[]; | ||
last(predicate?: (item: T, index: number) => boolean): T | undefined; | ||
} | ||
@@ -7,2 +9,15 @@ | ||
return this.length > 0 ? this.map(predicate).reduce((p: any, n: any) => p.concat(n)) : []; | ||
}; | ||
Array.prototype.last = function (predicate?: (item: any, index: number) => boolean): any { | ||
if (predicate) { | ||
for (let i = this.length - 1; i >= 0; i--) { | ||
if (predicate(this[i], i)) { | ||
return this[i]; | ||
} | ||
} | ||
} | ||
else { | ||
return this[this.length - 1]; | ||
} | ||
}; |
@@ -8,2 +8,3 @@ import "./extensions/ArrayExtensions"; | ||
export * from "./types/Type"; | ||
export * from "./types/Uuid"; | ||
export * from "./utils/Logger"; |
Sorry, the diff of this file is not supported yet
74240
31
1043