sendwend 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hdsuperman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,40 @@
1
- # Temporary Holding Version
1
+ # SendWend
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Get the last value of a finite iterable or async iterable with constant extra memory. Zero dependencies. Supports ESM, CommonJS, and TypeScript.
4
+
5
+ ```sh
6
+ npm install sendwend
7
+ ```
8
+
9
+ ```js
10
+ import { last, lastAsync } from 'sendwend';
11
+
12
+ last([1, 2, 3]); // 3
13
+ last([], 'empty'); // 'empty'
14
+ last(new Set(['a', 'b'])); // 'b'
15
+
16
+ async function* values() {
17
+ yield 1;
18
+ yield 2;
19
+ }
20
+
21
+ await lastAsync(values()); // 2
22
+ await lastAsync([Promise.resolve(1), Promise.resolve(2)]); // 2
23
+ ```
24
+
25
+ CommonJS: `const { last, lastAsync } = require('sendwend');`
26
+
27
+ This early release provides the iterable helpers below. The workflow orchestration API is not included in this release.
28
+
29
+ Project website: https://sendwend.com
30
+
31
+ ## API
32
+
33
+ - `last(iterable, fallback?)`: returns the final value, or the fallback if the input is empty. The default fallback is `undefined`.
34
+ - `lastAsync(iterable, fallback?)`: returns a Promise for the final value or fallback. Accepts sync and async iterables and awaits values from sync iterables.
35
+
36
+ Both functions consume the entire input once, run in O(n) time, and use O(1) extra memory. Use finite inputs only. Iterator errors propagate to the caller. An actual last value of `undefined` is returned as-is, even when a fallback is provided. The async function follows JavaScript's `for await...of` semantics.
37
+
38
+ ## License
39
+
40
+ MIT
package/index.cjs ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ /** Get the last value of a finite iterable, or fallback when empty. */
4
+ function last(iterable, fallback) {
5
+ let result = fallback;
6
+ for (const value of iterable) result = value;
7
+ return result;
8
+ }
9
+
10
+ /** Get the last value of a finite async or sync iterable, or fallback when empty. */
11
+ async function lastAsync(iterable, fallback) {
12
+ let result = fallback;
13
+ for await (const value of iterable) result = value;
14
+ return result;
15
+ }
16
+
17
+ exports.last = last;
18
+ exports.lastAsync = lastAsync;
package/index.d.cts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function last<T>(iterable: Iterable<T>): T | undefined;
2
+ export declare function last<T, F>(iterable: Iterable<T>, fallback: F): T | F;
3
+ export declare function lastAsync<T>(iterable: AsyncIterable<T> | Iterable<T>): Promise<Awaited<T> | undefined>;
4
+ export declare function lastAsync<T, F>(iterable: AsyncIterable<T> | Iterable<T>, fallback: F): Promise<Awaited<T> | Awaited<F>>;
package/index.d.mts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function last<T>(iterable: Iterable<T>): T | undefined;
2
+ export declare function last<T, F>(iterable: Iterable<T>, fallback: F): T | F;
3
+ export declare function lastAsync<T>(iterable: AsyncIterable<T> | Iterable<T>): Promise<Awaited<T> | undefined>;
4
+ export declare function lastAsync<T, F>(iterable: AsyncIterable<T> | Iterable<T>, fallback: F): Promise<Awaited<T> | Awaited<F>>;
package/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { last, lastAsync } from './index.cjs';
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "sendwend",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Get the last value of a finite iterable or async iterable with constant extra memory.",
5
+ "main": "./index.cjs",
6
+ "module": "./index.mjs",
7
+ "types": "./index.d.cts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./index.d.mts",
12
+ "default": "./index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./index.d.cts",
16
+ "default": "./index.cjs"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "index.cjs",
22
+ "index.mjs",
23
+ "index.d.cts",
24
+ "index.d.mts"
25
+ ],
26
+ "scripts": {
27
+ "test": "node --test test.cjs"
28
+ },
29
+ "sideEffects": false,
30
+ "keywords": [
31
+ "iterable",
32
+ "async-iterable",
33
+ "last",
34
+ "iterator"
35
+ ],
36
+ "author": "hdsuperman",
37
+ "license": "MIT",
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "registry": "https://registry.npmjs.org/"
41
+ },
42
+ "homepage": "https://sendwend.com"
43
+ }