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

@azure/core-util

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/core-util - npm Package Compare versions

Comparing version 1.0.1-alpha.20220523.1 to 1.0.1-alpha.20220815.2

dist-esm/src/typeGuards.js

1

dist-esm/src/index.js

@@ -9,2 +9,3 @@ // Copyright (c) Microsoft Corporation.

export { computeSha256Hash, computeSha256Hmac } from "./sha256";
export { isDefined, isObjectWithProperties, objectHasProperty } from "./typeGuards";
//# sourceMappingURL=index.js.map

@@ -121,2 +121,36 @@ 'use strict';

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Helper TypeGuard that checks if something is defined or not.
* @param thing - Anything
*/
function isDefined(thing) {
return typeof thing !== "undefined" && thing !== null;
}
/**
* Helper TypeGuard that checks if the input is an object with the specified properties.
* @param thing - Anything.
* @param properties - The name of the properties that should appear in the object.
*/
function isObjectWithProperties(thing, properties) {
if (!isDefined(thing) || typeof thing !== "object") {
return false;
}
for (const property of properties) {
if (!objectHasProperty(thing, property)) {
return false;
}
}
return true;
}
/**
* Helper TypeGuard that checks if the input is an object with the specified property.
* @param thing - Any object.
* @param property - The name of the property that should appear in the object.
*/
function objectHasProperty(thing, property) {
return (isDefined(thing) && typeof thing === "object" && property in thing);
}
exports.computeSha256Hash = computeSha256Hash;

@@ -127,5 +161,8 @@ exports.computeSha256Hmac = computeSha256Hmac;

exports.getRandomIntegerInclusive = getRandomIntegerInclusive;
exports.isDefined = isDefined;
exports.isError = isError;
exports.isNode = isNode;
exports.isObject = isObject;
exports.isObjectWithProperties = isObjectWithProperties;
exports.objectHasProperty = objectHasProperty;
//# sourceMappingURL=index.js.map

2

package.json
{
"name": "@azure/core-util",
"version": "1.0.1-alpha.20220523.1",
"version": "1.0.1-alpha.20220815.2",
"description": "Core library for shared utility methods",

@@ -5,0 +5,0 @@ "sdk-type": "client",

@@ -37,2 +37,7 @@ /**

/**
* Helper TypeGuard that checks if something is defined or not.
* @param thing - Anything
*/
export declare function isDefined<T>(thing: T | undefined | null): thing is T;
/**
* Typeguard for an error object shape (has name and message)

@@ -52,2 +57,14 @@ * @param e - Something caught by a catch clause.

/**
* Helper TypeGuard that checks if the input is an object with the specified properties.
* @param thing - Anything.
* @param properties - The name of the properties that should appear in the object.
*/
export declare function isObjectWithProperties<Thing, PropertyName extends string>(thing: Thing, properties: PropertyName[]): thing is Thing & Record<PropertyName, unknown>;
/**
* Helper TypeGuard that checks if the input is an object with the specified property.
* @param thing - Any object.
* @param property - The name of the property that should appear in the object.
*/
export declare function objectHasProperty<Thing, PropertyName extends string>(thing: Thing, property: PropertyName): thing is Thing & Record<PropertyName, unknown>;
/**
* A generic shape for a plain JS object.

@@ -54,0 +71,0 @@ */

@@ -42,2 +42,8 @@ /**

/**
* Helper TypeGuard that checks if something is defined or not.
* @param thing - Anything
*/
export declare function isDefined<T>(thing: T | undefined | null): thing is T;
/**
* Typeguard for an error object shape (has name and message)

@@ -60,2 +66,16 @@ * @param e - Something caught by a catch clause.

/**
* Helper TypeGuard that checks if the input is an object with the specified properties.
* @param thing - Anything.
* @param properties - The name of the properties that should appear in the object.
*/
export declare function isObjectWithProperties<Thing, PropertyName extends string>(thing: Thing, properties: PropertyName[]): thing is Thing & Record<PropertyName, unknown>;
/**
* Helper TypeGuard that checks if the input is an object with the specified property.
* @param thing - Any object.
* @param property - The name of the property that should appear in the object.
*/
export declare function objectHasProperty<Thing, PropertyName extends string>(thing: Thing, property: PropertyName): thing is Thing & Record<PropertyName, unknown>;
/**
* A generic shape for a plain JS object.

@@ -62,0 +82,0 @@ */

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