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

@sirutils/core

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sirutils/core - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

LICENSE

4

dist/index.js
// @bun
var G=(_)=>{return(L)=>`${_}.${L}`};var Z=G("@sirutils/core"),D={logger:Z("logger"),group:Z("group-missused"),wrap:Z("wrap-missused"),forward:Z("forward"),capsule:Z("capsule"),createActions:Z("create-actions"),createLogger:Z("create-logger"),env:Z("invalid-env"),lazy:Z("lazy-unexpected")},Y=G("@sirutils/core#plugin-system"),H={initContext:Y("init-context"),contextUnexpected:Y("context-unexpected"),locked:Y("locked"),create:Y("create"),use:Y("use"),lookup:Y("lookup"),lookupByOption:Y("lookup-by-option"),get:Y("get"),pluginInitiator:Y("plugin-initiator"),notFound:Y("not-found")};import{err as g,ok as W}from"neverthrow";var p=(_)=>{const L=Reflect.ownKeys(_);for(let X of L){const q=_[X];if(q&&typeof q==="object"||typeof q==="function")p(q)}return Object.freeze(_)},z=()=>{const _=[];return function(L,X){if(typeof X!=="object"||X===null)return X;while(_.length>0&&_.at(-1)!==this)_.pop();if(_.includes(X))return"[Circular]";return _.push(X),X}};class V extends Promise{#X;#L=null;#_=[];constructor(_){super((L)=>{L()});this.#X=_}static from(_){return new V((L)=>{L(_())})}get promise(){if(!this.#L)this.#L=new Promise(this.#X);return this.#L}then(_,L){return this.promise.then(_,(X)=>{const q=X instanceof A?X.appendCause(...this.#_).appendData(X):A.create(D.lazy,"catch missused",...this.#_).appendData(X);if(L)return L(q);return})}catch(_){return this.promise.catch((L)=>{const X=L instanceof A?L.appendCause(...this.#_).appendData(L):A.create(D.lazy,"catch missused",...this.#_).appendData(L);if(_)return _(X);return})}finally(_){return this.promise.finally(_)}appendCause(..._){for(let L of _)if(L&&this.#_[this.#_.length-1]!==L)this.#_.push(L);return this}}class A extends Error{_;L;X;q;B;constructor(_,L,X=[],q=[],B=Date.now()){super();this.name=_;this.message=L;this.cause=X;this.data=q;this.timestamp=B}appendCause(..._){for(let L of _)if(L&&this.cause[this.cause.length-1]!==L)this.cause.push(L);return this}asResult(..._){return g(this.appendCause.apply(this,_))}appendData(..._){for(let L of _)if(!this.data.includes(L))this.data.push(L);return this}throw(..._){throw this.appendCause.apply(this,_)}stringify(){return JSON.stringify({...this,data:this.data},z(),2)}static create=(_,L,...X)=>{if(X)return new A(_,L,X.filter((q)=>!!q));return new A(_,L)}}var O=(_)=>{return typeof _==="object"&&typeof _?.then==="function"},k=(_,...L)=>{if(_.isErr()){if(L)_.error.appendCause(...L);throw _.error}return _.value},R=(_,...L)=>{if(_ instanceof A)return _.appendCause(...L);return A.create(D.group,`${_}`).appendCause(...L).appendData(_)},B_=(_,...L)=>{try{const X=_();if(X instanceof V)return W(X.appendCause(...L));if(O(X))return X.then((q)=>W(q),(q)=>R(q,...L).asResult());return W(X)}catch(X){return R(X,...L).asResult()}},S=(_,...L)=>{if(_ instanceof A)return _.appendCause(...L);return A.create(D.wrap,`${_}`).appendCause(...L).appendData(_)},D_=(_,...L)=>{return(...X)=>{try{const q=_(...X);if(q instanceof V)return W(q.appendCause(...L));if(O(q))return q.then((B)=>W(B),(B)=>S(B,...L).asResult());return W(q)}catch(q){return S(q,...L).asResult()}}},T=(_,...L)=>{if(_ instanceof A)throw _.appendCause(...L);const X=L[0]===D.capsule;if(X)L.shift();return A.create(X?D.capsule:D.forward,`${_}`).appendCause(...L).appendData(_)},f=(_,...L)=>{try{const X=_();if(X instanceof V)return X.appendCause(...L);if(O(X))return X.then((q)=>q,(q)=>T(q,...L).throw());return X}catch(X){throw T(X,...L)}},J=(_,...L)=>{return(...X)=>f(()=>_(...X),D.capsule,...L)};var x=(_,L,X)=>{const q=new Proxy({...X??{},init:(...B)=>{try{_(q,...B)}catch(Q){if(Q instanceof A)throw Q.appendCause(H.initContext,L)}}},{get:(...B)=>{const[Q,U]=B;if(U===Symbol.toStringTag)return Q;const M=Reflect.get(...B);if(typeof M==="undefined"&&U!=="then")A.create(H.contextUnexpected,`Cannot read properties of context.undefined reading(${U})`,L).throw();return M},set:(...B)=>{return Reflect.set(...B)}});return q};import{consola as c}from"consola";var y=J((_,L=Number.MAX_SAFE_INTEGER)=>c.create({formatOptions:{date:!0,compact:!1,colors:!0},defaults:{tag:_},level:L}),D.createLogger);var w=y(D.logger);var{semver:d}=globalThis.Bun;var P=(_)=>{return J((L,X)=>{const q=_.$boundPlugins.find((B)=>B.meta.name===L&&d.satisfies(B.meta.version,X||"*"));if(!q)A.create(H.notFound,`${L}@${X??"*"} not found`).throw();return q},H.get,_.$cause)};var{semver:l}=globalThis.Bun;var b=(_)=>{return J((L,X)=>{const q=_.$boundPlugins.find((B)=>B.meta.name===L&&l.satisfies(B.meta.version,X||"*"));if(!q)A.create(H.notFound,`${L}@${X??"*"} not found`).throw();return q?.api},H.lookup,_.$cause)};var m=(_)=>{return J((L,X)=>{const q=_.$boundPlugins.find((B)=>B.options[L]===X);if(!q)A.create(H.notFound,`${L}:${X} not found`).throw();return q?.api},H.lookupByOption,_.$cause)};var E=(_)=>{return J((L)=>{if(!_.$boundPlugins.includes(L))_.$boundPlugins.push(L);return!0},H.use,_.$cause)};var p_=J((_,L,X,q)=>{let B=!1;const Q=[];_.name=_.name.split("@sirutils/").join("");const U=`${_.name}@${_.version}-${(Math.random()+1).toString(36).substring(2)}`,M=async($,...v)=>{const K=x((N,I)=>{if(I&&!Object.hasOwn(N,"options"))N.options=I},X,{meta:_,$id:U,$cause:X,$boundPlugins:[]}),C=$?{...q??{},...$}:void 0;K.init(C),K.use=E(K),K.get=P(K),K.lookup=b(K),K.lookupByOption=m(K);for(let N of v)K.use(N);K.api=await f(()=>L(K),H.pluginInitiator,X);for(let N of Q)Object.assign(K.api,await N(K,X));return K};return M.register=($)=>{if(B)return A.create(H.locked,`${U} is locked`,X).throw();if(Q.includes($))w.warn("actionInitiator registered some actions twice");else Q.push($);return M},M.lock=()=>{if(B)return A.create(H.locked,`${U} is already locked`,X).throw();return B=!0,M},Object.freeze(M)},H.create);var l_=(_,L)=>{return J(async(X,q)=>{const B=await _(X);return Object.fromEntries(Object.entries(B).map(([Q,U])=>[Q,typeof U==="function"?J(U,`${L}#${Q}`,D.createActions,q,X.$cause):U]))},L,D.createActions)};import{ok as u}from"neverthrow";class j{_;L;X;constructor(_,L,X){this.name=_;this.message=L;this.data=X}asResult(){return u(this)}static create(_,L,X){return new j(_,L,X)}}class F{_;constructor(_){this.value=_}isSome(){return!0}isNone(){return!1}orElse(_){return this}unwrapOr(_){return this.value}unwrap(){return this.value}}class h{value=null;isSome(){return!1}isNone(){return!0}orElse(_){return new F(_)}unwrapOr(_){return _}unwrap(){return this.value}}var i=(_)=>new F(_),o=()=>new h,t_=(_)=>_===null||typeof _==="undefined"?o():i(_);var _L=J((_,L="bun")=>{const X=L==="bun"&&typeof Bun!=="undefined"?Bun.env:process.env,q=_(X);for(let[B,Q]of Object.entries(q))if(!Q)k(A.create(D.env,`ENV.${B} is not valid`).asResult());return q},D.env);export*from"neverthrow";export{D_ as wrap,k as unwrap,G as tagBuilder,i as some,H as pluginSystemTags,o as none,B_ as group,z as getCircularReplacer,f as forward,_L as extractEnvs,p as deepFreeze,p_ as createPlugin,y as createLogger,x as createContext,l_ as createActions,D as coreTags,J as capsule,t_ as auto,F as Some,j as ProjectMessage,A as ProjectError,h as None,V as Lazy};
var G=(_)=>{return(L)=>`${_}.${L}`};var A=G("@sirutils/core"),H={logger:A("logger"),group:A("group-missused"),wrap:A("wrap-missused"),forward:A("forward"),capsule:A("capsule"),createActions:A("create-actions"),createLogger:A("create-logger"),env:A("invalid-env"),lazy:A("lazy-unexpected")},Z=G("@sirutils/core#plugin-system"),J={initContext:Z("init-context"),contextUnexpected:Z("context-unexpected"),locked:Z("locked"),create:Z("create"),use:Z("use"),lookup:Z("lookup"),lookupByOption:Z("lookup-by-option"),get:Z("get"),pluginInitiator:Z("plugin-initiator"),notFound:Z("not-found")};import{err as g,ok as W}from"neverthrow";var p=(_)=>{const L=Reflect.ownKeys(_);for(let X of L){const q=_[X];if(q&&typeof q==="object"||typeof q==="function")p(q)}return Object.freeze(_)},z=()=>{const _=[];return function(L,X){if(typeof X!=="object"||X===null)return X;while(_.length>0&&_.at(-1)!==this)_.pop();if(_.includes(X))return"[Circular]";return _.push(X),X}};class V extends Promise{#X;#L=null;#_=[];constructor(_){super((L)=>{L()});this.#X=_}static from(_){return new V((L)=>{L(_())})}get promise(){if(!this.#L)this.#L=new Promise(this.#X);return this.#L}then(_,L){return this.promise.then(_,(X)=>{const q=X instanceof B?X.appendCause(...this.#_).appendData(X):B.create(H.lazy,"catch missused",...this.#_).appendData(X);if(L)return L(q);return})}catch(_){return this.promise.catch((L)=>{const X=L instanceof B?L.appendCause(...this.#_).appendData(L):B.create(H.lazy,"catch missused",...this.#_).appendData(L);if(_)return _(X);return})}finally(_){return this.promise.finally(_)}appendCause(..._){for(let L of _)if(L&&this.#_[this.#_.length-1]!==L)this.#_.push(L);return this}}class B extends Error{_;L;X;q;D;constructor(_,L,X=[],q=[],D=Date.now()){super();this.name=_;this.message=L;this.cause=X;this.data=q;this.timestamp=D}appendCause(..._){for(let L of _)if(L&&this.cause[this.cause.length-1]!==L)this.cause.push(L);return this}asResult(..._){return g(this.appendCause.apply(this,_))}appendData(..._){for(let L of _)if(!this.data.includes(L))this.data.push(L);return this}throw(..._){throw this.appendCause.apply(this,_)}stringify(){return JSON.stringify({...this,data:this.data},z(),2)}static create=(_,L,...X)=>{if(X)return new B(_,L,X.filter((q)=>!!q));return new B(_,L)}}var O=(_)=>{return typeof _==="object"&&typeof _?.then==="function"},k=(_,...L)=>{if(_.isErr()){if(L)_.error.appendCause(...L);throw _.error}return _.value},R=(_,...L)=>{if(_ instanceof B)return _.appendCause(...L);return B.create(H.group,`${_}`).appendCause(...L).appendData(_)},D_=(_,...L)=>{try{const X=_();if(X instanceof V)return W(X.appendCause(...L));if(O(X))return X.then((q)=>W(q),(q)=>R(q,...L).asResult());return W(X)}catch(X){return R(X,...L).asResult()}},S=(_,...L)=>{if(_ instanceof B)return _.appendCause(...L);return B.create(H.wrap,`${_}`).appendCause(...L).appendData(_)},H_=(_,...L)=>{return(...X)=>{try{const q=_(...X);if(q instanceof V)return W(q.appendCause(...L));if(O(q))return q.then((D)=>W(D),(D)=>S(D,...L).asResult());return W(q)}catch(q){return S(q,...L).asResult()}}},T=(_,...L)=>{if(_ instanceof B)throw _.appendCause(...L);const X=L[0]===H.capsule;if(X)L.shift();return B.create(X?H.capsule:H.forward,`${_}`).appendCause(...L).appendData(_)},f=(_,...L)=>{try{const X=_();if(X instanceof V)return X.appendCause(...L);if(O(X))return X.then((q)=>q,(q)=>T(q,...L).throw());return X}catch(X){throw T(X,...L)}},K=(_,...L)=>{return(...X)=>f(()=>_(...X),H.capsule,...L)};var x=(_,L,X)=>{const q=new Proxy({...X??{},init:(...D)=>{try{_(q,...D)}catch(U){if(U instanceof B)throw U.appendCause(J.initContext,L)}}},{get:(...D)=>{const[U,Y]=D;if(Y===Symbol.toStringTag)return U;const M=Reflect.get(...D);if(typeof M==="undefined"&&Y!=="then")B.create(J.contextUnexpected,`Cannot read properties of context.undefined reading(${Y})`,L).throw();return M},set:(...D)=>{return Reflect.set(...D)}});return q};import{consola as c}from"consola";var y=K((_,L=Number.MAX_SAFE_INTEGER)=>c.create({formatOptions:{date:!0,compact:!1,colors:!0},defaults:{tag:_},level:L}),H.createLogger);var w=y(H.logger);var{semver:d}=globalThis.Bun;var P=(_)=>{return K((L,X)=>{const q=_.$boundPlugins.find((D)=>D.meta.name===L&&d.satisfies(D.meta.version,X||"*"));if(!q)B.create(J.notFound,`${L}@${X??"*"} not found`).throw();return q},J.get,_.$cause)};var{semver:l}=globalThis.Bun;var m=(_)=>{return K((L,X)=>{const q=_.$boundPlugins.find((D)=>D.meta.name===L&&l.satisfies(D.meta.version,X||"*"));if(!q)B.create(J.notFound,`${L}@${X??"*"} not found`).throw();return q?.api},J.lookup,_.$cause)};var b=(_)=>{return K((L,X)=>{const q=_.$boundPlugins.find((D)=>D.options[L]===X);if(!q)B.create(J.notFound,`${L}:${X} not found`).throw();return q?.api},J.lookupByOption,_.$cause)};var E=(_)=>{return K((L)=>{if(!_.$boundPlugins.includes(L))_.$boundPlugins.push(L);return!0},J.use,_.$cause)};var p_=K((_,L,X,q)=>{let D=!1;const U=[];_.name=_.name.split("@sirutils/").join("");const Y=`${_.name}@${_.version}-${(Math.random()+1).toString(36).substring(2)}`,M=async($,...v)=>{const Q=x((N,I)=>{if(I&&!Object.hasOwn(N,"options"))N.options=I},X,{meta:_,$id:Y,$cause:X,$boundPlugins:[]}),C=$?{...q??{},...$}:void 0;Q.init(C),Q.use=E(Q),Q.get=P(Q),Q.lookup=m(Q),Q.lookupByOption=b(Q);for(let N of v)Q.use(N);Q.api=await f(()=>L(Q),J.pluginInitiator,X);for(let N of U)Object.assign(Q.api,await N(Q,X));return Q};return M.register=($)=>{if(D)return B.create(J.locked,`${Y} is locked`,X).throw();if(U.includes($))w.warn("actionInitiator registered some actions twice");else U.push($);return M},M.lock=()=>{if(D)return B.create(J.locked,`${Y} is already locked`,X).throw();return D=!0,M},Object.freeze(M)},J.create);var l_=(_,L)=>{return K(async(X,q)=>{const D=await _(X);return Object.fromEntries(Object.entries(D).map(([U,Y])=>[U,typeof Y==="function"?K(Y,`${L}#${U}`,H.createActions,q,X.$cause):Y]))},L,H.createActions)};import{ok as u}from"neverthrow";class j{_;L;X;constructor(_,L,X){this.name=_;this.message=L;this.data=X}asResult(){return u(this)}static create(_,L,X){return new j(_,L,X)}}class F{_;constructor(_){this.value=_}isSome(){return!0}isNone(){return!1}orElse(_){return this}unwrapOr(_){return this.value}unwrap(){return this.value}}class h{value=null;isSome(){return!1}isNone(){return!0}orElse(_){return new F(_)}unwrapOr(_){return _}unwrap(){return this.value}}var i=(_)=>new F(_),o=()=>new h,r_=(_)=>_===null||typeof _==="undefined"?o():i(_);var _L=K((_,L="bun")=>{const X=L==="bun"&&typeof Bun!=="undefined"?Bun.env:process.env,q=_(X);for(let[D,U]of Object.entries(q))if(!U)k(B.create(H.env,`ENV.${D} is not valid`).asResult());return q},H.env);export*from"neverthrow";export{H_ as wrap,k as unwrap,G as tagBuilder,i as some,J as pluginSystemTags,o as none,D_ as group,z as getCircularReplacer,f as forward,_L as extractEnvs,p as deepFreeze,p_ as createPlugin,y as createLogger,x as createContext,l_ as createActions,H as coreTags,K as capsule,r_ as auto,F as Some,j as ProjectMessage,B as ProjectError,h as None,V as Lazy};
//# debugId=FE9ECCB6EC50614464756E2164756E21
//# debugId=13F7D6B818374B3164756E2164756E21
// @bun
import{ok as z}from"neverthrow";class y{b;q;x;constructor(b,q,x){this.name=b;this.message=q;this.data=x}asResult(){return z(this)}static create(b,q,x){return new y(b,q,x)}}export{y as ProjectMessage};
import{ok as z}from"neverthrow";class x{f;p;q;constructor(f,p,q){this.name=f;this.message=p;this.data=q}asResult(){return z(this)}static create(f,p,q){return new x(f,p,q)}}export{x as ProjectMessage};
//# debugId=59232EC1457AC7A864756E2164756E21
//# debugId=60CA561497FB5A1764756E2164756E21
{
"name": "@sirutils/core",
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"files": ["dist"],
"files": [
"dist"
],
"exports": {

@@ -13,3 +15,3 @@ ".": {

"devDependencies": {
"@sirutils/builder": "workspace:*"
"@sirutils/builder": "0.1.1"
},

@@ -21,2 +23,2 @@ "dependencies": {

}
}
}

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

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

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