New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@soos-io/api-client

Package Overview
Dependencies
Maintainers
1
Versions
255
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soos-io/api-client - npm Package Compare versions

Comparing version 0.1.8-pre.1 to 0.1.8

5

dist/utilities.d.ts
declare const isNil: (value: unknown) => value is null | undefined;
declare const isNilOrEmpty: (value: unknown) => value is null | undefined;
declare const isEmptyString: (value: string) => boolean;
declare const ensureValue: <T>(value: T | null | undefined, propertyName: string) => T;
declare const ensureNonEmptyValue: (value: string | null | undefined, propertyName: string) => string;
declare const ensureEnumValue: <T, TEnumObject extends Record<string, T> = Record<string, T>>(enumObject: TEnumObject, inputValue: string | null | undefined, excludeDefault?: keyof TEnumObject | undefined, ignoreCase?: boolean) => T | undefined;

@@ -10,2 +11,2 @@ declare const sleep: (ms: number) => Promise<unknown>;

declare const getEnvVariable: (name: string) => string | null;
export { isNil, isNilOrEmpty, ensureValue, ensureEnumValue, sleep, isUrlAvailable, obfuscateProperties, convertStringToBase64, getEnvVariable, };
export { isNil, isEmptyString, ensureValue, ensureEnumValue, ensureNonEmptyValue, sleep, isUrlAvailable, obfuscateProperties, convertStringToBase64, getEnvVariable, };

22

dist/utilities.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnvVariable = exports.convertStringToBase64 = exports.obfuscateProperties = exports.isUrlAvailable = exports.sleep = exports.ensureEnumValue = exports.ensureValue = exports.isNilOrEmpty = exports.isNil = void 0;
exports.getEnvVariable = exports.convertStringToBase64 = exports.obfuscateProperties = exports.isUrlAvailable = exports.sleep = exports.ensureNonEmptyValue = exports.ensureEnumValue = exports.ensureValue = exports.isEmptyString = exports.isNil = void 0;
const tslib_1 = require("tslib");
const axios_1 = tslib_1.__importStar(require("axios"));
const SOOSLogger_1 = require("./logging/SOOSLogger");
const isNil = (value) => value === null || value === undefined || value === "";
const isNil = (value) => value === null || value === undefined;
exports.isNil = isNil;
const isNilOrEmpty = (value) => {
if (isNil(value))
return true;
if (typeof value === "string")
return value.trim() === "";
return false;
const isEmptyString = (value) => {
return value.trim() === "";
};
exports.isNilOrEmpty = isNilOrEmpty;
exports.isEmptyString = isEmptyString;
const ensureValue = (value, propertyName) => {
if (isNilOrEmpty(value))
if (isNil(value))
throw new Error(`'${propertyName}' is required.`);

@@ -23,2 +19,8 @@ return value;

exports.ensureValue = ensureValue;
const ensureNonEmptyValue = (value, propertyName) => {
if (isNil(value) || isEmptyString(value))
throw new Error(`'${propertyName}' is required.`);
return value;
};
exports.ensureNonEmptyValue = ensureNonEmptyValue;
const ensureEnumValue = (enumObject, inputValue, excludeDefault, ignoreCase = true) => {

@@ -25,0 +27,0 @@ if (isNil(inputValue)) {

@@ -11,5 +11,2 @@ "use strict";

});
test("should return true for an empty string", () => {
expect((0, utilities_1.isNil)("")).toBe(true);
});
test("should return false for a non-nil value", () => {

@@ -19,17 +16,11 @@ expect((0, utilities_1.isNil)("string")).toBe(false);

});
describe("isNilOrEmpty", () => {
test("should return true for null", () => {
expect((0, utilities_1.isNilOrEmpty)(null)).toBe(true);
});
test("should return true for undefined", () => {
expect((0, utilities_1.isNilOrEmpty)(undefined)).toBe(true);
});
describe("isEmptyString", () => {
test("should return true for an empty string", () => {
expect((0, utilities_1.isNilOrEmpty)("")).toBe(true);
expect((0, utilities_1.isEmptyString)("")).toBe(true);
});
test("should return true for a string with only spaces", () => {
expect((0, utilities_1.isNilOrEmpty)(" ")).toBe(true);
expect((0, utilities_1.isEmptyString)(" ")).toBe(true);
});
test("should return false for a non-empty string", () => {
expect((0, utilities_1.isNilOrEmpty)("value")).toBe(false);
expect((0, utilities_1.isEmptyString)("value")).toBe(false);
});

@@ -44,5 +35,2 @@ });

});
test("should throw an error for an empty string", () => {
expect(() => (0, utilities_1.ensureValue)("", "property")).toThrow("'property' is required.");
});
test("should return the value for a non-nil value", () => {

@@ -52,2 +40,19 @@ expect((0, utilities_1.ensureValue)("value", "property")).toBe("value");

});
describe("ensureNonEmptyValue", () => {
test("should throw an error for null", () => {
expect(() => (0, utilities_1.ensureNonEmptyValue)(null, "property")).toThrow("'property' is required.");
});
test("should throw an error for undefined", () => {
expect(() => (0, utilities_1.ensureNonEmptyValue)(undefined, "property")).toThrow("'property' is required.");
});
test("should throw an error for an empty string", () => {
expect(() => (0, utilities_1.ensureNonEmptyValue)("", "property")).toThrow("'property' is required.");
});
test("should throw an error for a string with only spaces", () => {
expect(() => (0, utilities_1.ensureNonEmptyValue)(" ", "property")).toThrow("'property' is required.");
});
test("should return the value for a non-empty string", () => {
expect((0, utilities_1.ensureNonEmptyValue)("value", "property")).toBe("value");
});
});
describe("ensureEnumValue", () => {

@@ -60,5 +65,2 @@ test("should return undefined for null", () => {

});
test("should return undefined for an empty string", () => {
expect((0, utilities_1.ensureEnumValue)({ value: "value" }, "")).toBe(undefined);
});
test("should throw an error for an invalid enum value", () => {

@@ -65,0 +67,0 @@ expect(() => (0, utilities_1.ensureEnumValue)({ value: "value" }, "invalid")).toThrow("Invalid enum value 'invalid'. Valid options are: value.");

@@ -0,0 +0,0 @@ module.exports = {

{
"name": "@soos-io/api-client",
"version": "0.1.8-pre.1",
"version": "0.1.8",
"description": "This is the SOOS API Client for registered clients leveraging the various integrations to the SOOS platform.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -0,0 +0,0 @@ # [About SOOS](https://soos.io/)

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