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

@universal-packages/dynamic-api

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@universal-packages/dynamic-api - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

6

DynamicApi.d.ts
import { DynamicApiOptions, Dynamics } from './DynamicApi.types';
export default class DynamicApi {
export default class DynamicApi<D extends Record<string, any>> {
readonly options: DynamicApiOptions;

@@ -7,7 +7,7 @@ readonly dynamics: Dynamics;

loadDynamics(): Promise<void>;
performDynamic(name: string, payload?: Record<string, any>): Promise<any>;
performDynamic<N extends keyof D>(name: N, payload?: D[N]['payload']): Promise<D[N]['result']>;
private perform;
performDynamicSync(name: string, payload?: Record<string, any>): any;
performDynamicSync<N extends keyof D>(name: N, payload?: D[N]['payload']): D[N]['result'];
private performSync;
private getDynamicRegistry;
}

@@ -19,3 +19,3 @@ import DynamicApi from './DynamicApi';

export interface DynamicLike {
perform: (payload?: Record<string, any>, forHookResultOrDynamicApi?: any | DynamicApi, dynamicApi?: DynamicApi) => any | Promise<any>;
perform: (payload?: Record<string, any>, forHookResultOrDynamicApi?: any | DynamicApi<any>, dynamicApi?: DynamicApi<any>) => any | Promise<any>;
}

@@ -22,0 +22,0 @@ export interface DynamicClassLike {

{
"name": "@universal-packages/dynamic-api",
"version": "1.1.0",
"version": "1.2.0",
"description": "Dynamic decoupling-adapting system",

@@ -5,0 +5,0 @@ "author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)",

@@ -168,2 +168,20 @@ # Dynamic API

### Typing dynamics
Since all here is dynamic `performDynamic` takes generic payloads and return generic results, if you want to type your dynamics you can always create an interface typing the payload and the result of your dynamics.
```ts
interface DynamicNames {
calculate: {
payload: { fast: boolean }
result: string
}
}
const dynamicApi = new DynamicApi<DynamicNames>({ dynamicsLocation: './src' })
// Now result is string type and performDynamic will require a payload of the specific shape
const result = dynamicApi.performDynamic('calculate', { fast: true })
```
## Contributing

@@ -170,0 +188,0 @@

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