@frui.ts/helpers
Advanced tools
Comparing version 1.0.0-alpha.10 to 1.0.0-alpha.11
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) { | ||
var fn = descriptor.value; | ||
const 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}`); | ||
} | ||
var definingProperty = false; | ||
let definingProperty = false; | ||
return { | ||
configurable: true, | ||
get: function () { | ||
if (definingProperty || this === target.prototype || this.hasOwnProperty(propertyKey)) { | ||
get() { | ||
if (definingProperty || this === target.prototype || Object.prototype.hasOwnProperty.call(this, propertyKey)) { | ||
return fn; | ||
} | ||
var boundFn = fn.bind(this); | ||
const 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) { | ||
var result = class1; | ||
let 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) { | ||
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)); }); | ||
const getValue = valueSelector !== null && valueSelector !== void 0 ? valueSelector : ((x) => x); | ||
const result = new Map(); | ||
source.forEach(x => result.set(keySelector(x), getValue(x))); | ||
return result; | ||
@@ -8,0 +8,0 @@ } |
@@ -1,1 +0,1 @@ | ||
export declare function bind<T>(func: T & Function, target: any): T; | ||
export declare function bind<T extends Function>(func: T, target: any): T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bind = void 0; | ||
function bind(func, target) { | ||
@@ -4,0 +5,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) { | ||
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]); | ||
} | ||
const result = new Map(); | ||
for (const item of collection) { | ||
const key = selector(item); | ||
const bucket = result.get(key); | ||
if (bucket) { | ||
bucket.push(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); | ||
else { | ||
result.set(key, [item]); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
@@ -37,0 +15,0 @@ return result; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
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 }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ManualPromise = exports.groupBy = exports.createMap = exports.combineClassNames = exports.bound = void 0; | ||
var bound_1 = require("./bound"); | ||
exports.bound = bound_1.default; | ||
Object.defineProperty(exports, "bound", { enumerable: true, get: function () { return __importDefault(bound_1).default; } }); | ||
var combineClassNames_1 = require("./combineClassNames"); | ||
exports.combineClassNames = combineClassNames_1.default; | ||
Object.defineProperty(exports, "combineClassNames", { enumerable: true, get: function () { return __importDefault(combineClassNames_1).default; } }); | ||
var createMap_1 = require("./createMap"); | ||
exports.createMap = createMap_1.default; | ||
__export(require("./functionHelpers")); | ||
Object.defineProperty(exports, "createMap", { enumerable: true, get: function () { return __importDefault(createMap_1).default; } }); | ||
__exportStar(require("./disposable"), exports); | ||
__exportStar(require("./functionHelpers"), exports); | ||
var groupBy_1 = require("./groupBy"); | ||
exports.groupBy = groupBy_1.default; | ||
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return __importDefault(groupBy_1).default; } }); | ||
var manualPromise_1 = require("./manualPromise"); | ||
exports.ManualPromise = manualPromise_1.default; | ||
__export(require("./nameof")); | ||
__export(require("./observableHelpers")); | ||
__export(require("./typeHelpers")); | ||
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); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
export default class ManualPromise<T = any> { | ||
export default class ManualPromise<T = unknown> { | ||
promise: Promise<T>; | ||
@@ -7,4 +7,5 @@ status: "new" | "resolved" | "rejected"; | ||
constructor(); | ||
resolve(result?: T | PromiseLike<T>): void; | ||
resolve(result: T | PromiseLike<T>): void; | ||
resolve(): void; | ||
reject(reason: any): void; | ||
} |
@@ -12,39 +12,37 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_1 = require("mobx"); | ||
var ManualPromise = (function () { | ||
function ManualPromise() { | ||
var _this = this; | ||
const mobx_1 = require("mobx"); | ||
class ManualPromise { | ||
constructor() { | ||
this.status = "new"; | ||
this.promise = new Promise(function (resolve, reject) { | ||
_this.resolveCallback = resolve; | ||
_this.rejectCallback = reject; | ||
this.promise = new Promise((resolve, reject) => { | ||
this.resolveCallback = resolve; | ||
this.rejectCallback = reject; | ||
}); | ||
} | ||
ManualPromise.prototype.resolve = function (result) { | ||
resolve(result) { | ||
this.resolveCallback(result); | ||
this.status = "resolved"; | ||
}; | ||
ManualPromise.prototype.reject = function (reason) { | ||
} | ||
reject(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); | ||
return ManualPromise; | ||
}()); | ||
} | ||
} | ||
__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); | ||
exports.default = ManualPromise; | ||
//# sourceMappingURL=manualPromise.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nameof = function (name) { return name; }; | ||
exports.nameof = void 0; | ||
const nameof = (name) => name; | ||
exports.nameof = nameof; | ||
//# sourceMappingURL=nameof.js.map |
@@ -0,2 +1,3 @@ | ||
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: {}, property: string, value: any): void; | ||
export declare function ensureObservableProperty(target: BindingTarget, property: string, value: any): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_1 = require("mobx"); | ||
exports.ensureObservableProperty = void 0; | ||
const mobx_1 = require("mobx"); | ||
function ensureObservableProperty(target, property, value) { | ||
if (!mobx_1.isObservable(target)) { | ||
mobx_1.extendObservable(target, {}); | ||
if (!(0, mobx_1.isObservable)(target)) { | ||
(0, mobx_1.extendObservable)(target, {}); | ||
} | ||
mobx_1.set(target, property, value); | ||
(0, 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 && typeof item.add === "function" && typeof item.has === "function" && typeof item.delete === "function"; | ||
return !!item && (item instanceof Set || (0, mobx_1.isObservableSet)(item)); | ||
} | ||
exports.isSet = isSet; | ||
function isMap(item) { | ||
return item && typeof item.add === "function" && typeof item.has === "function" && typeof item.delete === "function"; | ||
return !!item && (item instanceof Map || (0, mobx_1.isObservableMap)(item)); | ||
} | ||
exports.isMap = isMap; | ||
//# sourceMappingURL=typeHelpers.js.map |
@@ -0,3 +1,5 @@ | ||
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 Map<any, any> | {}, TProperty extends BindingProperty<TTarget>, TRestrict = any> = (TTarget extends Map<any, infer V> ? V : TTarget[TProperty]) & TRestrict; | ||
export declare type PropertyType<TTarget extends BindingTarget, TProperty extends BindingProperty<TTarget>, TRestrict = unknown> = (TTarget extends Map<any, infer V> ? V : TTarget[TProperty]) & TRestrict; |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.0.0-alpha.10", | ||
"version": "1.0.0-alpha.11", | ||
"description": "Frui.ts helper functions", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "5454d007244bb9cdd28be5207a9f125f04a9ac43" | ||
"gitHead": "f9f70e1d4bcbe45b8b37f11f5dcdfd2ed9a523c7" | ||
} |
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
25259
232