Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frui.ts/helpers

Package Overview
Dependencies
Maintainers
5
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frui.ts/helpers - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

dist/busyWatcher.d.ts

229

dist/fruits-helpers.es.js

@@ -1,115 +0,164 @@

import { action, observable, isObservable, extendObservable, set, isObservableSet, isObservableMap } from "mobx";
function bound(target, propertyKey, descriptor) {
const fn = descriptor.value;
if (typeof fn !== "function") {
throw new Error(`@bound decorator can only be applied to methods, not ${typeof fn}`);
}
let definingProperty = false;
var P = Object.defineProperty;
var m = (t, e, s) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
var i = (t, e, s) => (m(t, typeof e != "symbol" ? e + "" : e, s), s);
import { action as a, ObservableMap as _, makeObservable as h, computed as j, observable as g, isObservable as B, makeAutoObservable as M, set as D, isObservableArray as k, isObservableSet as A, isObservableMap as T } from "mobx";
function S(t, e, s) {
const n = s.value;
if (typeof n != "function")
throw new Error(`@bound decorator can only be applied to methods, not ${typeof n}`);
let r = !1;
return {
configurable: true,
configurable: !0,
get() {
if (definingProperty || this === target.prototype || Object.prototype.hasOwnProperty.call(this, propertyKey)) {
return fn;
}
const boundFn = fn.bind(this);
definingProperty = true;
Object.defineProperty(this, propertyKey, {
value: boundFn,
configurable: true,
writable: true
});
definingProperty = false;
return boundFn;
if (r || this === t.prototype || Object.prototype.hasOwnProperty.call(this, e))
return n;
const o = n.bind(this);
return r = !0, Object.defineProperty(this, e, {
value: o,
configurable: !0,
writable: !0
}), r = !1, o;
}
};
}
function combineClassNames(class1, class2, class3, class4) {
let result = class1;
if (class2) {
result = result ? result + " " + class2 : class2;
var $ = Object.defineProperty, E = Object.getOwnPropertyDescriptor, v = (t, e, s, n) => {
for (var r = n > 1 ? void 0 : n ? E(e, s) : e, o = t.length - 1, u; o >= 0; o--)
(u = t[o]) && (r = (n ? u(e, s, r) : u(r)) || r);
return n && r && $(e, s, r), r;
};
class C {
constructor() {
i(this, "busyCounter", new _());
h(this);
}
if (class3) {
result = result ? result + " " + class3 : class3;
get isBusy() {
return this.busyCounter.size > 0;
}
if (class4) {
result = result ? result + " " + class4 : class4;
checkBusy(e) {
return this.busyCounter.has(e);
}
return result;
getBusyTicket(e = Symbol()) {
const s = this.busyCounter.get(e);
s ? this.busyCounter.set(e, s + 1) : this.busyCounter.set(e, 1);
let n = !1;
return a(() => {
if (!n) {
const r = this.busyCounter.get(e);
!r || r === 1 ? this.busyCounter.delete(e) : this.busyCounter.set(e, r - 1), n = !0;
}
});
}
watch(e) {
const s = this.getBusyTicket();
return e.then(s, s), e;
}
}
function createMap(source, keySelector, valueSelector) {
const getValue = valueSelector != null ? valueSelector : (x) => x;
const result = /* @__PURE__ */ new Map();
source.forEach((x) => result.set(keySelector(x), getValue(x)));
return result;
v([
j
], C.prototype, "isBusy", 1);
v([
a.bound
], C.prototype, "getBusyTicket", 1);
function V(t, e, s) {
const n = typeof t != "object", r = n ? t : Symbol(), o = (u, K, p) => {
const O = p.value;
p.value = function(...d) {
var y;
const c = (y = this.busyWatcher) == null ? void 0 : y.getBusyTicket(r), b = O.apply(this, d);
return c && (W(b) ? b.then(c, (w) => {
console.error(w), c();
}) : c()), b;
};
};
if (n)
return o;
if (!e || !s)
throw new Error("Wrong decorator use. PropertyKey and Descriptor must be provided");
return o(t, e, s);
}
function bind(func, target) {
return func.bind(target);
function W(t) {
return typeof (t == null ? void 0 : t.then) == "function";
}
function groupBy(collection, selector) {
const result = /* @__PURE__ */ new Map();
for (const item of collection) {
const key = selector(item);
const bucket = result.get(key);
if (bucket) {
bucket.push(item);
} else {
result.set(key, [item]);
}
function q(t, e, s, n) {
let r = t;
return e && (r = r ? r + " " + e : e), s && (r = r ? r + " " + s : s), n && (r = r ? r + " " + n : n), r;
}
function x(t, e, s) {
const n = s != null ? s : (o) => o, r = /* @__PURE__ */ new Map();
return t.forEach((o) => r.set(e(o), n(o))), r;
}
function G(t, e) {
return t.bind(e);
}
function H(t, e) {
const s = /* @__PURE__ */ new Map();
for (const n of t) {
const r = e(n), o = s.get(r);
o ? o.push(n) : s.set(r, [n]);
}
return result;
return s;
}
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i = decorators.length - 1, decorator; i >= 0; i--)
if (decorator = decorators[i])
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result)
__defProp(target, key, result);
return result;
var F = Object.defineProperty, z = Object.getOwnPropertyDescriptor, f = (t, e, s, n) => {
for (var r = n > 1 ? void 0 : n ? z(e, s) : e, o = t.length - 1, u; o >= 0; o--)
(u = t[o]) && (r = (n ? u(e, s, r) : u(r)) || r);
return n && r && F(e, s, r), r;
};
class ManualPromise {
class l {
constructor() {
this.status = "new";
this.promise = new Promise((resolve, reject) => {
this.resolveCallback = resolve;
this.rejectCallback = reject;
i(this, "promise");
i(this, "status", "new");
i(this, "resolveCallback");
i(this, "rejectCallback");
h(this), this.promise = new Promise((e, s) => {
this.resolveCallback = e, this.rejectCallback = s;
});
}
resolve(result) {
this.resolveCallback(result);
this.status = "resolved";
resolve(e) {
this.resolveCallback(e), this.status = "resolved";
}
reject(reason) {
this.rejectCallback(reason);
this.status = "rejected";
reject(e) {
this.rejectCallback(e), this.status = "rejected";
}
}
__decorateClass([
observable
], ManualPromise.prototype, "status", 2);
__decorateClass([
action.bound
], ManualPromise.prototype, "resolve", 1);
__decorateClass([
action.bound
], ManualPromise.prototype, "reject", 1);
const nameof = (name) => name;
function ensureObservableProperty(target, property, value) {
if (!isObservable(target)) {
extendObservable(target, {});
}
set(target, property, value);
f([
g
], l.prototype, "status", 2);
f([
a.bound
], l.prototype, "resolve", 1);
f([
a.bound
], l.prototype, "reject", 1);
const I = (t) => t;
function J(t, e, s) {
B(t) ? D(t, e, s) : (t[e] = s, M(t));
}
function isSet(item) {
return !!item && (item instanceof Set || isObservableSet(item));
function Q(t) {
return Array.isArray(t) || k(t);
}
function isMap(item) {
return !!item && (item instanceof Map || isObservableMap(item));
function R(t) {
return !!t && (t instanceof Set || A(t));
}
function onlyDefined(input) {
return !!input;
function U(t) {
return !!t && (t instanceof Map || T(t));
}
export { ManualPromise, bind, bound, combineClassNames, createMap, ensureObservableProperty, groupBy, isMap, isSet, nameof, onlyDefined };
function X(t) {
return !!t;
}
export {
C as BusyWatcher,
l as ManualPromise,
G as bind,
S as bound,
q as combineClassNames,
x as createMap,
J as ensureObservableProperty,
H as groupBy,
Q as isArrayLike,
U as isMap,
R as isSet,
I as nameof,
X as onlyDefined,
V as watchBusy
};
//# sourceMappingURL=fruits-helpers.es.js.map

@@ -1,2 +0,2 @@

(function(i,u){typeof exports=="object"&&typeof module!="undefined"?u(exports,require("mobx")):typeof define=="function"&&define.amd?define(["exports","mobx"],u):(i=typeof globalThis!="undefined"?globalThis:i||self,u(i["fruits-helpers"]={},i.mobx))})(this,function(i,u){"use strict";function l(e,n,r){const o=r.value;if(typeof o!="function")throw new Error(`@bound decorator can only be applied to methods, not ${typeof o}`);let t=!1;return{configurable:!0,get(){if(t||this===e.prototype||Object.prototype.hasOwnProperty.call(this,n))return o;const s=o.bind(this);return t=!0,Object.defineProperty(this,n,{value:s,configurable:!0,writable:!0}),t=!1,s}}}function b(e,n,r,o){let t=e;return n&&(t=t?t+" "+n:n),r&&(t=t?t+" "+r:r),o&&(t=t?t+" "+o:o),t}function p(e,n,r){const o=r!=null?r:s=>s,t=new Map;return e.forEach(s=>t.set(n(s),o(s))),t}function d(e,n){return e.bind(n)}function h(e,n){const r=new Map;for(const o of e){const t=n(o),s=r.get(t);s?s.push(o):r.set(t,[o])}return r}var y=Object.defineProperty,v=Object.getOwnPropertyDescriptor,a=(e,n,r,o)=>{for(var t=o>1?void 0:o?v(n,r):n,s=e.length-1,c;s>=0;s--)(c=e[s])&&(t=(o?c(n,r,t):c(t))||t);return o&&t&&y(n,r,t),t};class f{constructor(){this.status="new",this.promise=new Promise((n,r)=>{this.resolveCallback=n,this.rejectCallback=r})}resolve(n){this.resolveCallback(n),this.status="resolved"}reject(n){this.rejectCallback(n),this.status="rejected"}}a([u.observable],f.prototype,"status",2),a([u.action.bound],f.prototype,"resolve",1),a([u.action.bound],f.prototype,"reject",1);const O=e=>e;function P(e,n,r){u.isObservable(e)||u.extendObservable(e,{}),u.set(e,n,r)}function M(e){return!!e&&(e instanceof Set||u.isObservableSet(e))}function j(e){return!!e&&(e instanceof Map||u.isObservableMap(e))}function w(e){return!!e}i.ManualPromise=f,i.bind=d,i.bound=l,i.combineClassNames=b,i.createMap=p,i.ensureObservableProperty=P,i.groupBy=h,i.isMap=j,i.isSet=M,i.nameof=O,i.onlyDefined=w,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("mobx")):typeof define=="function"&&define.amd?define(["exports","mobx"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i["fruits-helpers"]={},i.mobx))})(this,function(i,o){"use strict";var N=Object.defineProperty;var q=(i,o,a)=>o in i?N(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var f=(i,o,a)=>(q(i,typeof o!="symbol"?o+"":o,a),a);function a(t,e,r){const s=r.value;if(typeof s!="function")throw new Error(`@bound decorator can only be applied to methods, not ${typeof s}`);let n=!1;return{configurable:!0,get(){if(n||this===t.prototype||Object.prototype.hasOwnProperty.call(this,e))return s;const u=s.bind(this);return n=!0,Object.defineProperty(this,e,{value:u,configurable:!0,writable:!0}),n=!1,u}}}var O=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(t,e,r,s)=>{for(var n=s>1?void 0:s?P(e,r):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(n=(s?c(e,r,n):c(n))||n);return s&&n&&O(e,r,n),n};class y{constructor(){f(this,"busyCounter",new o.ObservableMap);o.makeObservable(this)}get isBusy(){return this.busyCounter.size>0}checkBusy(e){return this.busyCounter.has(e)}getBusyTicket(e=Symbol()){const r=this.busyCounter.get(e);r?this.busyCounter.set(e,r+1):this.busyCounter.set(e,1);let s=!1;return o.action(()=>{if(!s){const n=this.busyCounter.get(e);!n||n===1?this.busyCounter.delete(e):this.busyCounter.set(e,n-1),s=!0}})}watch(e){const r=this.getBusyTicket();return e.then(r,r),e}}d([o.computed],y.prototype,"isBusy",1),d([o.action.bound],y.prototype,"getBusyTicket",1);function w(t,e,r){const s=typeof t!="object",n=s?t:Symbol(),u=(c,z,v)=>{const E=v.value;v.value=function(...F){var C;const b=(C=this.busyWatcher)==null?void 0:C.getBusyTicket(n),p=E.apply(this,F);return b&&(_(p)?p.then(b,L=>{console.error(L),b()}):b()),p}};if(s)return u;if(!e||!r)throw new Error("Wrong decorator use. PropertyKey and Descriptor must be provided");return u(t,e,r)}function _(t){return typeof(t==null?void 0:t.then)=="function"}function j(t,e,r,s){let n=t;return e&&(n=n?n+" "+e:e),r&&(n=n?n+" "+r:r),s&&(n=n?n+" "+s:s),n}function g(t,e,r){const s=r!=null?r:u=>u,n=new Map;return t.forEach(u=>n.set(e(u),s(u))),n}function B(t,e){return t.bind(e)}function M(t,e){const r=new Map;for(const s of t){const n=e(s),u=r.get(n);u?u.push(s):r.set(n,[s])}return r}var m=Object.defineProperty,D=Object.getOwnPropertyDescriptor,h=(t,e,r,s)=>{for(var n=s>1?void 0:s?D(e,r):e,u=t.length-1,c;u>=0;u--)(c=t[u])&&(n=(s?c(e,r,n):c(n))||n);return s&&n&&m(e,r,n),n};class l{constructor(){f(this,"promise");f(this,"status","new");f(this,"resolveCallback");f(this,"rejectCallback");o.makeObservable(this),this.promise=new Promise((e,r)=>{this.resolveCallback=e,this.rejectCallback=r})}resolve(e){this.resolveCallback(e),this.status="resolved"}reject(e){this.rejectCallback(e),this.status="rejected"}}h([o.observable],l.prototype,"status",2),h([o.action.bound],l.prototype,"resolve",1),h([o.action.bound],l.prototype,"reject",1);const T=t=>t;function k(t,e,r){o.isObservable(t)?o.set(t,e,r):(t[e]=r,o.makeAutoObservable(t))}function A(t){return Array.isArray(t)||o.isObservableArray(t)}function S(t){return!!t&&(t instanceof Set||o.isObservableSet(t))}function W(t){return!!t&&(t instanceof Map||o.isObservableMap(t))}function $(t){return!!t}i.BusyWatcher=y,i.ManualPromise=l,i.bind=B,i.bound=a,i.combineClassNames=j,i.createMap=g,i.ensureObservableProperty=k,i.groupBy=M,i.isArrayLike=A,i.isMap=W,i.isSet=S,i.nameof=T,i.onlyDefined=$,i.watchBusy=w,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
//# sourceMappingURL=fruits-helpers.umd.js.map
export { default as bound } from "./bound";
export { default as BusyWatcher, watchBusy } from "./busyWatcher";
export type { BusyWatcherKey, IBusyWatcher } from "./busyWatcher";
export { default as combineClassNames } from "./combineClassNames";

@@ -10,3 +12,4 @@ export { default as createMap } from "./createMap";

export * from "./observableHelpers";
export * from "./path";
export * from "./typeHelpers";
export * from "./types";

@@ -1,1 +0,1 @@

export declare const nameof: <T>(name: Extract<keyof T, string>) => string;
export declare const nameof: <T>(name: Extract<keyof T, string>) => Extract<keyof T, string>;

@@ -0,3 +1,4 @@

export declare function isArrayLike<T = any>(item: any): item is T[];
export declare function isSet<T = any>(item: any): item is Set<T>;
export declare function isMap<K = any, V = any>(item: any): item is Map<K, V>;
export declare function onlyDefined<T>(input: T | undefined): input is T;
export declare type Awaitable<T> = T | PromiseLike<T>;
export declare type Constructor<T, Arguments extends unknown[] = any[]> = new (...arguments_: Arguments) => 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 ConditionalKeys<Base, Condition> = NonNullable<{
[Key in keyof Base]: Base[Key] extends Condition ? Key : never;
}[keyof Base]>;
export declare type PropertyName<TTarget, TTypeRestriction = any> = ConditionalKeys<TTarget, TTypeRestriction> & string;
export declare type TypedBindingProperty<TTarget, TTypeRestriction> = TTarget extends Map<infer K, infer TValue> ? TValue extends TTypeRestriction ? K | undefined : never : PropertyName<TTarget, TTypeRestriction>;
export declare type ExtractTypeRestriction<T> = T extends TypedBindingProperty<any, infer TTypeRestriction> ? TTypeRestriction : T extends PropertyName<any, infer TTypeRestriction> ? TTypeRestriction : never;
export declare type PropertyType<TTarget extends BindingTarget, TProperty extends TypedBindingProperty<TTarget, any>> = TTarget extends Map<TProperty, infer TValue> ? TValue | undefined : TTarget[TProperty] & ExtractTypeRestriction<TProperty>;

@@ -6,3 +6,3 @@ {

},
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Frui.ts helper functions",

@@ -46,5 +46,5 @@ "keywords": [

"peerDependencies": {
"mobx": "^4.0.0 || ^5.0.0"
"mobx": "6"
},
"gitHead": "1a7897ad15a6a5be5adc7e67725f174a1dbc6394"
"gitHead": "5d7b8915490794c56dcad28698a47e6e2a904e4e"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc