@frui.ts/helpers
Advanced tools
Comparing version 1.0.0-alpha.9 to 1.0.0-alpha.10
export default function bound(target: any, propertyKey: string, descriptor: PropertyDescriptor): { | ||
configurable: boolean; | ||
get(): () => any; | ||
get(): any; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function bound(target, propertyKey, descriptor) { | ||
const fn = descriptor.value; | ||
var fn = descriptor.value; | ||
if (typeof fn !== "function") { | ||
throw new Error(`@bound decorator can only be applied to methods, not ${typeof fn}`); | ||
throw new Error("@bound decorator can only be applied to methods, not " + typeof fn); | ||
} | ||
let definingProperty = false; | ||
var definingProperty = false; | ||
return { | ||
configurable: true, | ||
get() { | ||
if (definingProperty || this === target.prototype || Object.prototype.hasOwnProperty.call(this, propertyKey)) { | ||
get: function () { | ||
if (definingProperty || this === target.prototype || this.hasOwnProperty(propertyKey)) { | ||
return fn; | ||
} | ||
const boundFn = fn.bind(this); | ||
var boundFn = fn.bind(this); | ||
definingProperty = true; | ||
@@ -17,0 +17,0 @@ Object.defineProperty(this, propertyKey, { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function combineClassNames(class1, class2, class3, class4) { | ||
let result = class1; | ||
var result = class1; | ||
if (class2) { | ||
@@ -6,0 +6,0 @@ result = result ? result + " " + class2 : class2; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function createMap(source, keySelector, valueSelector) { | ||
const getValue = valueSelector !== null && valueSelector !== void 0 ? valueSelector : ((x) => x); | ||
const result = new Map(); | ||
source.forEach(x => result.set(keySelector(x), getValue(x))); | ||
var getValue = valueSelector !== null && valueSelector !== void 0 ? valueSelector : (function (x) { return x; }); | ||
var result = new Map(); | ||
source.forEach(function (x) { return result.set(keySelector(x), getValue(x)); }); | ||
return result; | ||
@@ -8,0 +8,0 @@ } |
@@ -1,1 +0,1 @@ | ||
export declare function bind<T extends Function>(func: T, target: any): T; | ||
export declare function bind<T>(func: T & Function, target: any): T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bind = void 0; | ||
function bind(func, target) { | ||
@@ -5,0 +4,0 @@ return func.bind(target); |
"use strict"; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function groupBy(collection, selector) { | ||
const result = new Map(); | ||
for (const item of collection) { | ||
const key = selector(item); | ||
const bucket = result.get(key); | ||
if (bucket) { | ||
bucket.push(item); | ||
var e_1, _a; | ||
var result = new Map(); | ||
try { | ||
for (var collection_1 = __values(collection), collection_1_1 = collection_1.next(); !collection_1_1.done; collection_1_1 = collection_1.next()) { | ||
var item = collection_1_1.value; | ||
var key = selector(item); | ||
var bucket = result.get(key); | ||
if (bucket) { | ||
bucket.push(item); | ||
} | ||
else { | ||
result.set(key, [item]); | ||
} | ||
} | ||
else { | ||
result.set(key, [item]); | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (collection_1_1 && !collection_1_1.done && (_a = collection_1.return)) _a.call(collection_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
@@ -15,0 +37,0 @@ return result; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ManualPromise = exports.groupBy = exports.createMap = exports.combineClassNames = exports.bound = void 0; | ||
var bound_1 = require("./bound"); | ||
Object.defineProperty(exports, "bound", { enumerable: true, get: function () { return __importDefault(bound_1).default; } }); | ||
exports.bound = bound_1.default; | ||
var combineClassNames_1 = require("./combineClassNames"); | ||
Object.defineProperty(exports, "combineClassNames", { enumerable: true, get: function () { return __importDefault(combineClassNames_1).default; } }); | ||
exports.combineClassNames = combineClassNames_1.default; | ||
var createMap_1 = require("./createMap"); | ||
Object.defineProperty(exports, "createMap", { enumerable: true, get: function () { return __importDefault(createMap_1).default; } }); | ||
__exportStar(require("./disposable"), exports); | ||
__exportStar(require("./functionHelpers"), exports); | ||
exports.createMap = createMap_1.default; | ||
__export(require("./functionHelpers")); | ||
var groupBy_1 = require("./groupBy"); | ||
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return __importDefault(groupBy_1).default; } }); | ||
exports.groupBy = groupBy_1.default; | ||
var manualPromise_1 = require("./manualPromise"); | ||
Object.defineProperty(exports, "ManualPromise", { enumerable: true, get: function () { return __importDefault(manualPromise_1).default; } }); | ||
__exportStar(require("./nameof"), exports); | ||
__exportStar(require("./observableHelpers"), exports); | ||
__exportStar(require("./typeHelpers"), exports); | ||
__exportStar(require("./types"), exports); | ||
exports.ManualPromise = manualPromise_1.default; | ||
__export(require("./nameof")); | ||
__export(require("./observableHelpers")); | ||
__export(require("./typeHelpers")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
export default class ManualPromise<T = unknown> { | ||
export default class ManualPromise<T = any> { | ||
promise: Promise<T>; | ||
@@ -7,5 +7,4 @@ status: "new" | "resolved" | "rejected"; | ||
constructor(); | ||
resolve(result: T | PromiseLike<T>): void; | ||
resolve(): void; | ||
resolve(result?: T | PromiseLike<T>): void; | ||
reject(reason: any): void; | ||
} |
@@ -12,37 +12,39 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mobx_1 = require("mobx"); | ||
class ManualPromise { | ||
constructor() { | ||
var mobx_1 = require("mobx"); | ||
var ManualPromise = (function () { | ||
function ManualPromise() { | ||
var _this = this; | ||
this.status = "new"; | ||
this.promise = new Promise((resolve, reject) => { | ||
this.resolveCallback = resolve; | ||
this.rejectCallback = reject; | ||
this.promise = new Promise(function (resolve, reject) { | ||
_this.resolveCallback = resolve; | ||
_this.rejectCallback = reject; | ||
}); | ||
} | ||
resolve(result) { | ||
ManualPromise.prototype.resolve = function (result) { | ||
this.resolveCallback(result); | ||
this.status = "resolved"; | ||
} | ||
reject(reason) { | ||
}; | ||
ManualPromise.prototype.reject = function (reason) { | ||
this.rejectCallback(reason); | ||
this.status = "rejected"; | ||
} | ||
} | ||
__decorate([ | ||
mobx_1.observable, | ||
__metadata("design:type", String) | ||
], ManualPromise.prototype, "status", void 0); | ||
__decorate([ | ||
mobx_1.action.bound, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], ManualPromise.prototype, "resolve", null); | ||
__decorate([ | ||
mobx_1.action.bound, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], ManualPromise.prototype, "reject", null); | ||
}; | ||
__decorate([ | ||
mobx_1.observable, | ||
__metadata("design:type", String) | ||
], ManualPromise.prototype, "status", void 0); | ||
__decorate([ | ||
mobx_1.action.bound, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], ManualPromise.prototype, "resolve", null); | ||
__decorate([ | ||
mobx_1.action.bound, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], ManualPromise.prototype, "reject", null); | ||
return ManualPromise; | ||
}()); | ||
exports.default = ManualPromise; | ||
//# sourceMappingURL=manualPromise.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nameof = void 0; | ||
const nameof = (name) => name; | ||
exports.nameof = nameof; | ||
exports.nameof = function (name) { return name; }; | ||
//# sourceMappingURL=nameof.js.map |
@@ -1,3 +0,2 @@ | ||
import type { BindingTarget } from "./types"; | ||
export declare function ensureObservableProperty<K, V>(target: Map<K, V>, property: K, value: V): void; | ||
export declare function ensureObservableProperty(target: BindingTarget, property: string, value: any): void; | ||
export declare function ensureObservableProperty(target: {}, property: string, value: any): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ensureObservableProperty = void 0; | ||
const mobx_1 = require("mobx"); | ||
var mobx_1 = require("mobx"); | ||
function ensureObservableProperty(target, property, value) { | ||
if (!(0, mobx_1.isObservable)(target)) { | ||
(0, mobx_1.extendObservable)(target, {}); | ||
if (!mobx_1.isObservable(target)) { | ||
mobx_1.extendObservable(target, {}); | ||
} | ||
(0, mobx_1.set)(target, property, value); | ||
mobx_1.set(target, property, value); | ||
} | ||
exports.ensureObservableProperty = ensureObservableProperty; | ||
//# sourceMappingURL=observableHelpers.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isMap = exports.isSet = void 0; | ||
const mobx_1 = require("mobx"); | ||
function isSet(item) { | ||
return !!item && (item instanceof Set || (0, mobx_1.isObservableSet)(item)); | ||
return item && typeof item.add === "function" && typeof item.has === "function" && typeof item.delete === "function"; | ||
} | ||
exports.isSet = isSet; | ||
function isMap(item) { | ||
return !!item && (item instanceof Map || (0, mobx_1.isObservableMap)(item)); | ||
return item && typeof item.add === "function" && typeof item.has === "function" && typeof item.delete === "function"; | ||
} | ||
exports.isMap = isMap; | ||
//# sourceMappingURL=typeHelpers.js.map |
@@ -1,5 +0,3 @@ | ||
export declare type Awaitable<T> = T | PromiseLike<T>; | ||
export declare type BindingTarget = Map<any, any> | Record<string, any>; | ||
export declare type PropertyName<TTarget> = keyof TTarget & string; | ||
export declare type BindingProperty<TTarget> = TTarget extends Map<infer K, any> ? K : PropertyName<TTarget>; | ||
export declare type PropertyType<TTarget extends BindingTarget, TProperty extends BindingProperty<TTarget>, TRestrict = unknown> = (TTarget extends Map<any, infer V> ? V : TTarget[TProperty]) & TRestrict; | ||
export declare type PropertyType<TTarget extends Map<any, any> | {}, TProperty extends BindingProperty<TTarget>, TRestrict = any> = (TTarget extends Map<any, infer V> ? V : TTarget[TProperty]) & TRestrict; |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.0.0-alpha.9", | ||
"version": "1.0.0-alpha.10", | ||
"description": "Frui.ts helper functions", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "718298c96617555dd2121f87a2dfefb3ea16d039" | ||
"gitHead": "5454d007244bb9cdd28be5207a9f125f04a9ac43" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
233
24296