ensure-string
Advanced tools
Comparing version 0.1.0 to 0.1.1
# Changelog | ||
### [0.1.1](https://www.github.com/cheminfo/ensure-string/compare/v0.1.0...v0.1.1) (2021-04-28) | ||
### Bug Fixes | ||
* allow ArrayBuffer ([8d7abc1](https://www.github.com/cheminfo/ensure-string/commit/8d7abc1598b87c52c77155a61a6043642cd1cb3b)) | ||
## 0.1.0 (2021-04-27) | ||
@@ -4,0 +11,0 @@ |
@@ -15,3 +15,3 @@ 'use strict'; | ||
const { encoding = 'utf8' } = options; | ||
if (ArrayBuffer.isView(blob)) { | ||
if (ArrayBuffer.isView(blob) || blob instanceof ArrayBuffer) { | ||
const decoder = new TextDecoder(encoding); | ||
@@ -18,0 +18,0 @@ return decoder.decode(blob); |
{ | ||
"name": "ensure-string", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Ensure that we receive a text even if an ArrayBuffer is sent", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -8,4 +8,8 @@ # ensure-string | ||
Ensure that we receive a text even if an ArrayBuffer is sent. | ||
If required, convert the input value to a string. | ||
The input value may be a Buffer, ArrayBuffer, Int8Array. By default the conversion will consider that the text encoding is `utf8`. | ||
If the input value is a text no change is done. The method returns the value without further processing. | ||
## Installation | ||
@@ -12,0 +16,0 @@ |
@@ -11,3 +11,3 @@ /** | ||
const { encoding = 'utf8' } = options; | ||
if (ArrayBuffer.isView(blob)) { | ||
if (ArrayBuffer.isView(blob) || blob instanceof ArrayBuffer) { | ||
const decoder = new TextDecoder(encoding); | ||
@@ -14,0 +14,0 @@ return decoder.decode(blob); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5682
45