@jscad/io-utils 3.0.0-alpha.0 → 3.0.2-alpha.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.2-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@3.0.1-alpha.0...@jscad/io-utils@3.0.2-alpha.0) (2025-09-06)
7
+
8
+ **Note:** Version bump only for package @jscad/io-utils
9
+
10
+ ## [3.0.1-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.22...@jscad/io-utils@3.0.1-alpha.0) (2025-01-03)
11
+
12
+ ### Bug Fixes
13
+
14
+ * **io:** fix io after V3 refactoring ([7a12bbd](https://github.com/jscad/OpenJSCAD.org/commit/7a12bbdb7b4b3df792a4c5b3c8b30a6a985a48f0))
15
+
6
16
  # [3.0.0-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.22...@jscad/io-utils@3.0.0-alpha.0) (2023-10-09)
7
17
 
8
18
  ### Bug Fixes
package/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2017-2021 JSCAD Organization
4
+ Copyright (c) 2017-2025 JSCAD Organization
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscad/io-utils",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.2-alpha.0",
4
4
  "description": "Utilities for JSCAD IO Packages",
5
5
  "homepage": "https://openjscad.xyz/",
6
6
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -34,9 +34,9 @@
34
34
  ],
35
35
  "license": "MIT",
36
36
  "devDependencies": {
37
- "@jscad/modeling": "3.0.0-alpha.0",
37
+ "@jscad/modeling": "3.0.2-alpha.0",
38
38
  "ava": "^4.3.3",
39
39
  "c8": "^8.0.0"
40
40
  },
41
- "gitHead": "3656d36ed9cd738ab884e86aae5a2ce08d52adf7"
41
+ "gitHead": "ac80d1a7cb0a8efb21aff9193d4a8bccb6e31f1c"
42
42
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Ensure the give buffer is a string, or decode the buffer contents into a string.
3
+ * @return {string} contents of the given buffer as a string
4
+ * @alias module:io/utils.ensureString
5
+ */
6
+ export const ensureString = (stringOrArrayBuffer, defaultBinaryEncoding = 'utf-8') => {
7
+ if (typeof (stringOrArrayBuffer) === 'string') {
8
+ return stringOrArrayBuffer;
9
+ }
10
+
11
+ return new TextDecoder(defaultBinaryEncoding).decode(new Uint8Array(stringOrArrayBuffer));
12
+ }
package/src/index.js CHANGED
@@ -9,3 +9,4 @@ export { makeBlob } from './makeBlob.js'
9
9
  export { BinaryReader } from './BinaryReader.js'
10
10
  export { Blob } from './Blob.js'
11
11
  export { stringify } from './stringify.js'
12
+ export { ensureString } from './ensureString.js'