Skip to content

Instantly share code, notes, and snippets.

@resynth1943
Created December 17, 2020 21:53
Show Gist options
  • Save resynth1943/d6f6ad3eaea651de4fa6bcebfd8d93b8 to your computer and use it in GitHub Desktop.
Save resynth1943/d6f6ad3eaea651de4fa6bcebfd8d93b8 to your computer and use it in GitHub Desktop.
A DI library in 952B
const n=Object.assign(Symbol("DI.Nothing"),{__nothing__:!0});function e(n){return Symbol(`DI.Key(${n})`)}function o(e,o=n,r=!0){r&&function(n){throw new Error(n||"This code needs to run inside a domain execution context.")}();const{cache:t}=undefined,i=t.has(e)?t.get(e):o;if(i===n)throw new Error(`The current domain does not have a provider for key "${String(e)}", and a default value has not been provided.`);return i}function r(n,e){return o(n,e,!0)}function t(n,e){return o(n,e,!1)}const i=Object.prototype.hasOwnProperty;function u(n,e){return{key:n,provide:e}}function c(n){return u(e("DI.AnyProvider"),n)}function d(n){return r(n.key,n.provide)}function a(n){return t(n.key,n.provide)}function f(n){return"object"==typeof n&&"symbol"==typeof n.key&&(e=n,o="provide",i.call(e,o));var e,o}export{n as Nothing,e as createKey,c as createProvider,f as isProvider,u as provide,r as useKey,t as useLibraryKey,a as useLibraryProvider,d as useProvider};
//# sourceMappingURL=inject.bundle.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment