Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ensure-string

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ensure-string - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

4

lib-esm/index.js

@@ -0,1 +1,2 @@

import isutf8 from 'isutf8';
/**

@@ -30,4 +31,7 @@ * Ensure that the data is string. If it is an ArrayBuffer it will be converted to string using TextDecoder.

}
//@ts-expect-error an ArrayBuffer is also ok
if (!isutf8(blob))
return 'latin1';
return 'utf-8';
}
//# sourceMappingURL=index.js.map

8

lib/index.d.ts

@@ -0,4 +1,6 @@

import type { TextData } from 'cheminfo-types';
export interface EnsureStringOptions {
/** Specify the encoding, by default 'utf8' or 'utf16'
* @default 'utf8' or utf16 if there is BOM utf16
/**
* Specify the encoding, by default 'utf8' or 'utf16'
* @default 'utf8' or utf16 if there is BOM utf16 or latin1 if it is not utf8
*/

@@ -13,2 +15,2 @@ encoding?: string;

*/
export declare function ensureString(blob: string | ArrayBuffer | Uint8Array, options?: EnsureStringOptions): string;
export declare function ensureString(blob: TextData, options?: EnsureStringOptions): string;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureString = void 0;
const isutf8_1 = __importDefault(require("isutf8"));
/**

@@ -34,4 +38,7 @@ * Ensure that the data is string. If it is an ArrayBuffer it will be converted to string using TextDecoder.

}
//@ts-expect-error an ArrayBuffer is also ok
if (!(0, isutf8_1.default)(blob))
return 'latin1';
return 'utf-8';
}
//# sourceMappingURL=index.js.map
{
"name": "ensure-string",
"version": "1.1.0",
"version": "1.2.0",
"description": "Ensure that we receive a text even if an ArrayBuffer is sent",

@@ -44,11 +44,15 @@ "main": "./lib/index.js",

"devDependencies": {
"@types/jest": "^27.0.1",
"eslint": "^7.32.0",
"eslint-config-cheminfo-typescript": "^8.0.9",
"jest": "^27.1.1",
"prettier": "^2.3.2",
"@types/jest": "^27.4.1",
"eslint": "^8.13.0",
"eslint-config-cheminfo-typescript": "^10.4.0",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.3",
"typescript": "^4.4.2"
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
},
"dependencies": {
"cheminfo-types": "^1.1.0",
"isutf8": "^4.0.0"
}
}

@@ -0,4 +1,8 @@

import type { TextData } from 'cheminfo-types';
import isutf8 from 'isutf8';
export interface EnsureStringOptions {
/** Specify the encoding, by default 'utf8' or 'utf16'
* @default 'utf8' or utf16 if there is BOM utf16
/**
* Specify the encoding, by default 'utf8' or 'utf16'
* @default 'utf8' or utf16 if there is BOM utf16 or latin1 if it is not utf8
*/

@@ -15,3 +19,3 @@ encoding?: string;

export function ensureString(
blob: string | ArrayBuffer | Uint8Array,
blob: TextData,
options: EnsureStringOptions = {},

@@ -42,3 +46,6 @@ ): string {

}
//@ts-expect-error an ArrayBuffer is also ok
if (!isutf8(blob)) return 'latin1';
return 'utf-8';
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc