Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@datastream/base64

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datastream/base64 - npm Package Compare versions

Comparing version
0.0.42
to
0.1.4
+18
index.d.ts
// Copyright 2026 will Farrell, and datastream contributors.
// SPDX-License-Identifier: MIT
import type { StreamOptions } from "@datastream/core";
export function base64EncodeStream(
options?: Record<string, unknown>,
streamOptions?: StreamOptions,
): unknown;
export function base64DecodeStream(
options?: Record<string, unknown>,
streamOptions?: StreamOptions,
): unknown;
declare const _default: {
encodeStream: typeof base64EncodeStream;
decodeStream: typeof base64DecodeStream;
};
export default _default;
<div align="center">
<h1>&lt;datastream&gt; `base64`</h1>
<img alt="datastream logo" src="https://raw.githubusercontent.com/willfarrell/datastream/main/docs/img/datastream-logo.svg"/>
<p><strong>Base64 encoding and decoding streams.</strong></p>
<p>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-unit.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-unit.yml/badge.svg" alt="GitHub Actions unit test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-dast.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-dast.yml/badge.svg" alt="GitHub Actions dast test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-perf.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-perf.yml/badge.svg" alt="GitHub Actions perf test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-sast.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-sast.yml/badge.svg" alt="GitHub Actions SAST test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-lint.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-lint.yml/badge.svg" alt="GitHub Actions lint test status"></a>
<br/>
<a href="https://www.npmjs.com/package/@datastream/base64"><img alt="npm version" src="https://img.shields.io/npm/v/@datastream/base64.svg"></a>
<a href="https://packagephobia.com/result?p=@datastream/base64"><img src="https://packagephobia.com/badge?p=@datastream/base64" alt="npm install size"></a>
<a href="https://www.npmjs.com/package/@datastream/base64">
<img alt="npm weekly downloads" src="https://img.shields.io/npm/dw/@datastream/base64.svg"></a>
<a href="https://www.npmjs.com/package/@datastream/base64#provenance">
<img alt="npm provenance" src="https://img.shields.io/badge/provenance-Yes-brightgreen"></a>
<br/>
<a href="https://scorecard.dev/viewer/?uri=github.com/willfarrell/datastream"><img src="https://api.scorecard.dev/projects/github.com/willfarrell/datastream/badge" alt="Open Source Security Foundation (OpenSSF) Scorecard"></a>
<a href="https://slsa.dev"><img src="https://slsa.dev/images/gh-badge-level3.svg" alt="SLSA 3"></a>
<a href="https://github.com/willfarrell/datastream/blob/main/docs/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg"></a>
<a href="https://biomejs.dev"><img alt="Checked with Biome" src="https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome"></a>
<a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
<a href="https://github.com/willfarrell/datastream/blob/main/package.json#L32">
<img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-95%25-brightgreen"></a>
</p>
<p>You can read the documentation at: <a href="https://datastream.js.org">https://datastream.js.org</a></p>
</div>
## Install
To install datastream you can use NPM:
```bash
npm install --save @datastream/base64
```
## Documentation and examples
For documentation and examples, refer to the main [datastream monorepo on GitHub](https://github.com/willfarrell/datastream) or [datastream official website](https://datastream.js.org).
## Contributing
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/willfarrell/datastream/issues) or to [submit Pull Requests](https://github.com/willfarrell/datastream/pulls).
## License
Licensed under [MIT License](LICENSE). Copyright (c) 2026 [will Farrell](https://github.com/willfarrell), and [datastream contributors](https://github.com/willfarrell/datastream/graphs/contributors).
+9
-9
import { createTransformStream } from "@datastream/core";
const base64EncodeStream = (_options, streamOptions = {}) => {
let extra;
const base64EncodeStream = (_options = {}, streamOptions = {}) => {
let extra = "";
const transform = (chunk, enqueue) => {
if (extra) {
chunk = Buffer.concat([extra, chunk]);
extra = null;
chunk = extra + chunk;
extra = "";
}

@@ -14,7 +14,7 @@ const remaining = chunk.length % 3;

}
enqueue(Buffer.from(chunk).toString("base64"));
enqueue(btoa(chunk));
};
const flush = (enqueue) => {
if (extra) {
enqueue(Buffer.from(extra).toString("base64"));
enqueue(btoa(extra));
}

@@ -24,3 +24,3 @@ };

};
const base64DecodeStream = (_options, streamOptions = {}) => {
const base64DecodeStream = (_options = {}, streamOptions = {}) => {
let extra = "";

@@ -32,7 +32,7 @@ const transform = (chunk, enqueue) => {

chunk = chunk.slice(0, chunk.length - remaining);
enqueue(Buffer.from(chunk, "base64"));
enqueue(atob(chunk));
};
const flush = (enqueue) => {
if (extra) {
enqueue(Buffer.from(extra, "base64"));
enqueue(atob(extra));
}

@@ -39,0 +39,0 @@ };

{
"version": 3,
"sources": ["index.node.js"],
"sourcesContent": ["import { createTransformStream } from \"@datastream/core\";\n\n// TODO replace with web version\nexport const base64EncodeStream = (_options, streamOptions = {}) => {\n\tlet extra;\n\tconst transform = (chunk, enqueue) => {\n\t\tif (extra) {\n\t\t\tchunk = Buffer.concat([extra, chunk]);\n\t\t\textra = null;\n\t\t}\n\n\t\t// 3 bytes == 4 char\n\t\tconst remaining = chunk.length % 3;\n\t\tif (remaining > 0) {\n\t\t\textra = chunk.slice(chunk.length - remaining);\n\t\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\t\t}\n\n\t\tenqueue(Buffer.from(chunk).toString(\"base64\"));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(Buffer.from(extra).toString(\"base64\"));\n\t\t}\n\t};\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport const base64DecodeStream = (_options, streamOptions = {}) => {\n\tlet extra = \"\";\n\tconst transform = (chunk, enqueue) => {\n\t\tchunk = extra + chunk;\n\n\t\t// 4 char == 3 bytes\n\t\tconst remaining = chunk.length % 4;\n\n\t\textra = chunk.slice(chunk.length - remaining);\n\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\n\t\tenqueue(Buffer.from(chunk, \"base64\"));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(Buffer.from(extra, \"base64\"));\n\t\t}\n\t};\n\tstreamOptions.decodeStrings = false;\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport default {\n\tencodeStream: base64EncodeStream,\n\tdecodeStream: base64DecodeStream,\n};\n"],
"mappings": "AAAA,SAAS,6BAA6B;AAG/B,MAAM,qBAAqB,CAAC,UAAU,gBAAgB,CAAC,MAAM;AACnE,MAAI;AACJ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,QAAI,OAAO;AACV,cAAQ,OAAO,OAAO,CAAC,OAAO,KAAK,CAAC;AACpC,cAAQ;AAAA,IACT;AAGA,UAAM,YAAY,MAAM,SAAS;AACjC,QAAI,YAAY,GAAG;AAClB,cAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,cAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAAA,IAChD;AAEA,YAAQ,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ,CAAC;AAAA,EAC9C;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ,CAAC;AAAA,IAC9C;AAAA,EACD;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEO,MAAM,qBAAqB,CAAC,UAAU,gBAAgB,CAAC,MAAM;AACnE,MAAI,QAAQ;AACZ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,YAAQ,QAAQ;AAGhB,UAAM,YAAY,MAAM,SAAS;AAEjC,YAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,YAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAE/C,YAAQ,OAAO,KAAK,OAAO,QAAQ,CAAC;AAAA,EACrC;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,OAAO,KAAK,OAAO,QAAQ,CAAC;AAAA,IACrC;AAAA,EACD;AACA,gBAAc,gBAAgB;AAC9B,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEA,IAAO,qBAAQ;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AACf;",
"sourcesContent": ["// Copyright 2026 will Farrell, and datastream contributors.\n// SPDX-License-Identifier: MIT\nimport { createTransformStream } from \"@datastream/core\";\n\nexport const base64EncodeStream = (_options = {}, streamOptions = {}) => {\n\tlet extra = \"\";\n\tconst transform = (chunk, enqueue) => {\n\t\tif (extra) {\n\t\t\tchunk = extra + chunk;\n\t\t\textra = \"\";\n\t\t}\n\n\t\t// 3 bytes == 4 char\n\t\tconst remaining = chunk.length % 3;\n\t\tif (remaining > 0) {\n\t\t\textra = chunk.slice(chunk.length - remaining);\n\t\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\t\t}\n\n\t\tenqueue(btoa(chunk));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(btoa(extra));\n\t\t}\n\t};\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport const base64DecodeStream = (_options = {}, streamOptions = {}) => {\n\tlet extra = \"\";\n\tconst transform = (chunk, enqueue) => {\n\t\tchunk = extra + chunk;\n\n\t\t// 4 char == 3 bytes\n\t\tconst remaining = chunk.length % 4;\n\n\t\textra = chunk.slice(chunk.length - remaining);\n\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\n\t\tenqueue(atob(chunk));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(atob(extra));\n\t\t}\n\t};\n\tstreamOptions.decodeStrings = false;\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport default {\n\tencodeStream: base64EncodeStream,\n\tdecodeStream: base64DecodeStream,\n};\n"],
"mappings": "AAEA,SAAS,6BAA6B;AAE/B,MAAM,qBAAqB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,MAAM;AACxE,MAAI,QAAQ;AACZ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,QAAI,OAAO;AACV,cAAQ,QAAQ;AAChB,cAAQ;AAAA,IACT;AAGA,UAAM,YAAY,MAAM,SAAS;AACjC,QAAI,YAAY,GAAG;AAClB,cAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,cAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAAA,IAChD;AAEA,YAAQ,KAAK,KAAK,CAAC;AAAA,EACpB;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,KAAK,KAAK,CAAC;AAAA,IACpB;AAAA,EACD;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEO,MAAM,qBAAqB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,MAAM;AACxE,MAAI,QAAQ;AACZ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,YAAQ,QAAQ;AAGhB,UAAM,YAAY,MAAM,SAAS;AAEjC,YAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,YAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAE/C,YAAQ,KAAK,KAAK,CAAC;AAAA,EACpB;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,KAAK,KAAK,CAAC;AAAA,IACpB;AAAA,EACD;AACA,gBAAc,gBAAgB;AAC9B,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEA,IAAO,qBAAQ;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AACf;",
"names": []
}

@@ -7,3 +7,3 @@ import { createTransformStream } from "@datastream/core";

chunk = extra + chunk;
extra = null;
extra = "";
}

@@ -10,0 +10,0 @@ const remaining = chunk.length % 3;

{
"version": 3,
"sources": ["index.web.js"],
"sourcesContent": ["import { createTransformStream } from \"@datastream/core\";\n\nexport const base64EncodeStream = (_options = {}, streamOptions = {}) => {\n\tlet extra = \"\";\n\tconst transform = (chunk, enqueue) => {\n\t\tif (extra) {\n\t\t\tchunk = extra + chunk;\n\t\t\textra = null;\n\t\t}\n\n\t\t// 3 bytes == 4 char\n\t\tconst remaining = chunk.length % 3;\n\t\tif (remaining > 0) {\n\t\t\textra = chunk.slice(chunk.length - remaining);\n\t\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\t\t}\n\n\t\tenqueue(btoa(chunk));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(btoa(extra));\n\t\t}\n\t};\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport const base64DecodeStream = (_options = {}, streamOptions = {}) => {\n\tlet extra = \"\";\n\tconst transform = (chunk, enqueue) => {\n\t\tchunk = extra + chunk;\n\n\t\t// 4 char == 3 bytes\n\t\tconst remaining = chunk.length % 4;\n\n\t\textra = chunk.slice(chunk.length - remaining);\n\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\n\t\tenqueue(atob(chunk));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(atob(extra));\n\t\t}\n\t};\n\tstreamOptions.decodeStrings = false;\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport default {\n\tencodeStream: base64EncodeStream,\n\tdecodeStream: base64DecodeStream,\n};\n"],
"mappings": "AAAA,SAAS,6BAA6B;AAE/B,MAAM,qBAAqB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,MAAM;AACxE,MAAI,QAAQ;AACZ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,QAAI,OAAO;AACV,cAAQ,QAAQ;AAChB,cAAQ;AAAA,IACT;AAGA,UAAM,YAAY,MAAM,SAAS;AACjC,QAAI,YAAY,GAAG;AAClB,cAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,cAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAAA,IAChD;AAEA,YAAQ,KAAK,KAAK,CAAC;AAAA,EACpB;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,KAAK,KAAK,CAAC;AAAA,IACpB;AAAA,EACD;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEO,MAAM,qBAAqB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,MAAM;AACxE,MAAI,QAAQ;AACZ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,YAAQ,QAAQ;AAGhB,UAAM,YAAY,MAAM,SAAS;AAEjC,YAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,YAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAE/C,YAAQ,KAAK,KAAK,CAAC;AAAA,EACpB;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,KAAK,KAAK,CAAC;AAAA,IACpB;AAAA,EACD;AACA,gBAAc,gBAAgB;AAC9B,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEA,IAAO,oBAAQ;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AACf;",
"sourcesContent": ["// Copyright 2026 will Farrell, and datastream contributors.\n// SPDX-License-Identifier: MIT\nimport { createTransformStream } from \"@datastream/core\";\n\nexport const base64EncodeStream = (_options = {}, streamOptions = {}) => {\n\tlet extra = \"\";\n\tconst transform = (chunk, enqueue) => {\n\t\tif (extra) {\n\t\t\tchunk = extra + chunk;\n\t\t\textra = \"\";\n\t\t}\n\n\t\t// 3 bytes == 4 char\n\t\tconst remaining = chunk.length % 3;\n\t\tif (remaining > 0) {\n\t\t\textra = chunk.slice(chunk.length - remaining);\n\t\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\t\t}\n\n\t\tenqueue(btoa(chunk));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(btoa(extra));\n\t\t}\n\t};\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport const base64DecodeStream = (_options = {}, streamOptions = {}) => {\n\tlet extra = \"\";\n\tconst transform = (chunk, enqueue) => {\n\t\tchunk = extra + chunk;\n\n\t\t// 4 char == 3 bytes\n\t\tconst remaining = chunk.length % 4;\n\n\t\textra = chunk.slice(chunk.length - remaining);\n\t\tchunk = chunk.slice(0, chunk.length - remaining);\n\n\t\tenqueue(atob(chunk));\n\t};\n\tconst flush = (enqueue) => {\n\t\tif (extra) {\n\t\t\tenqueue(atob(extra));\n\t\t}\n\t};\n\tstreamOptions.decodeStrings = false;\n\treturn createTransformStream(transform, flush, streamOptions);\n};\n\nexport default {\n\tencodeStream: base64EncodeStream,\n\tdecodeStream: base64DecodeStream,\n};\n"],
"mappings": "AAEA,SAAS,6BAA6B;AAE/B,MAAM,qBAAqB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,MAAM;AACxE,MAAI,QAAQ;AACZ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,QAAI,OAAO;AACV,cAAQ,QAAQ;AAChB,cAAQ;AAAA,IACT;AAGA,UAAM,YAAY,MAAM,SAAS;AACjC,QAAI,YAAY,GAAG;AAClB,cAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,cAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAAA,IAChD;AAEA,YAAQ,KAAK,KAAK,CAAC;AAAA,EACpB;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,KAAK,KAAK,CAAC;AAAA,IACpB;AAAA,EACD;AACA,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEO,MAAM,qBAAqB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,MAAM;AACxE,MAAI,QAAQ;AACZ,QAAM,YAAY,CAAC,OAAO,YAAY;AACrC,YAAQ,QAAQ;AAGhB,UAAM,YAAY,MAAM,SAAS;AAEjC,YAAQ,MAAM,MAAM,MAAM,SAAS,SAAS;AAC5C,YAAQ,MAAM,MAAM,GAAG,MAAM,SAAS,SAAS;AAE/C,YAAQ,KAAK,KAAK,CAAC;AAAA,EACpB;AACA,QAAM,QAAQ,CAAC,YAAY;AAC1B,QAAI,OAAO;AACV,cAAQ,KAAK,KAAK,CAAC;AAAA,IACpB;AAAA,EACD;AACA,gBAAc,gBAAgB;AAC9B,SAAO,sBAAsB,WAAW,OAAO,aAAa;AAC7D;AAEA,IAAO,oBAAQ;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AACf;",
"names": []
}
{
"name": "@datastream/base64",
"version": "0.0.42",
"description": "",
"version": "0.1.4",
"description": "Base64 encoding and decoding transform streams",
"type": "module",

@@ -13,3 +13,3 @@ "engines": {

},
"main": "./index.web.mjs",
"main": "./index.node.mjs",
"module": "./index.web.mjs",

@@ -22,6 +22,2 @@ "exports": {

"default": "./index.node.mjs"
},
"__require": {
"types": "./index.d.ts",
"default": "./index.node.cjs"
}

@@ -42,3 +38,2 @@ },

"*.mjs",
"*.cjs",
"*.map",

@@ -71,5 +66,4 @@ "*.d.ts"

"dependencies": {
"@datastream/core": "0.0.42"
},
"gitHead": "6ddc0fadabf5f3702a51aebae1fc6b252c6ae8d4"
"@datastream/core": "0.1.4"
}
}