invokecore 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -0
- package/package.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Invoke Core
|
|
4
|
+
|
|
5
|
+
### Primitive invocation utilities for composing application logic.
|
|
6
|
+
|
|
7
|
+
[](https://www.typescriptlang.org/) [](package.json) [](https://ai.mosa.sh)
|
|
8
|
+
|
|
9
|
+
[ai.mosa.sh](https://ai.mosa.sh) · [mosa.sh](https://mosa.sh)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
Invoke Core is a tiny, dependency-free base for calling application functions.
|
|
14
|
+
Follow development at [ai.mosa.sh](https://ai.mosa.sh).
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm i invokecore
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { once } from "invokecore";
|
|
22
|
+
|
|
23
|
+
const initialize = once(() => "ready");
|
|
24
|
+
initialize(); // "ready"
|
|
25
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Creates a function that invokes its callback at most once and returns its first result. */
|
|
2
|
+
export function once(callback) {
|
|
3
|
+
let called = false;
|
|
4
|
+
let result;
|
|
5
|
+
return (...arguments_) => {
|
|
6
|
+
if (!called) {
|
|
7
|
+
result = callback(...arguments_);
|
|
8
|
+
called = true;
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "invokecore",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Primitive invocation utilities for composing application logic.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" } },
|
|
9
|
+
"files": ["dist", "README.md"],
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"scripts": { "build": "tsc --project tsconfig.json", "prepublishOnly": "npm run build" },
|
|
12
|
+
"keywords": ["function", "functional", "utilities", "composition"],
|
|
13
|
+
"homepage": "https://ai.mosa.sh",
|
|
14
|
+
"author": "Mosanic <dev@mosanic.io>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"engines": { "node": ">=20" },
|
|
17
|
+
"publishConfig": { "access": "public" },
|
|
18
|
+
"devDependencies": { "typescript": "^5.9.3" }
|
|
19
|
+
}
|