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

@wixc3/common

Package Overview
Dependencies
Maintainers
70
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wixc3/common - npm Package Compare versions

Comparing version 13.0.1 to 13.1.0

src/test/errors.unit.ts

18

dist/cjs/errors.d.ts

@@ -13,2 +13,14 @@ /**

/**
* Creates an error with error code. Helpful when `instanceof` can't be used
* because the error was serialized and then deserialized.
* @example
* ```ts
* try {
* throw new ErrorWithCode('message', { code: 'ENOENT' });
* } catch (error) {
* if (getErrorCode(toError(error)) === 'ENOENT') {
* // ...
* }
* }
* ```
*/

@@ -44,3 +56,9 @@ export declare class ErrorWithCode extends Error {

};
/**
* Checks if the `error` is an object compatible with the Error interface; that is,
* it has properties 'name' and 'message' of type string. The object could be an
* instance of an Error, or it could be some other kind of object that has these
* properties.
*/
export declare function isErrorLikeObject(error: unknown): error is Error;
//# sourceMappingURL=errors.d.ts.map

22

dist/cjs/errors.js

@@ -21,2 +21,14 @@ "use strict";

/**
* Creates an error with error code. Helpful when `instanceof` can't be used
* because the error was serialized and then deserialized.
* @example
* ```ts
* try {
* throw new ErrorWithCode('message', { code: 'ENOENT' });
* } catch (error) {
* if (getErrorCode(toError(error)) === 'ENOENT') {
* // ...
* }
* }
* ```
*/

@@ -70,8 +82,12 @@ class ErrorWithCode extends Error {

exports.errorToPlainObject = errorToPlainObject;
/**
* Checks if the `error` is an object compatible with the Error interface; that is,
* it has properties 'name' and 'message' of type string. The object could be an
* instance of an Error, or it could be some other kind of object that has these
* properties.
*/
function isErrorLikeObject(error) {
return ((0, objects_1.isPlainObject)(error) &&
typeof error.name === 'string' &&
typeof error.message === 'string');
return (0, objects_1.isObject)(error) && typeof error.name === 'string' && typeof error.message === 'string';
}
exports.isErrorLikeObject = isErrorLikeObject;
//# sourceMappingURL=errors.js.map

@@ -28,2 +28,14 @@ import type { UnionToIntersection } from './types';

/**
* Checks if value is an object, e.g. a plain object, an array, a function,
* a regex, but not a primitive value.
*
* Common usage scenario:
* ```ts
* isObject(value) && value.foo === 'bar';
* // Instead of:
* typeof value === 'object' && value !== null && 'foo' in value && value.foo === 'bar';
* ```
*/
export declare function isObject(value: unknown): value is Readonly<Record<string | number | symbol, unknown>>;
/**
* Checks that value is a POJO

@@ -30,0 +42,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.remap = exports.getIn = exports.defaults = exports.reverseObject = exports.newMacrotask = exports.awaitRecord = exports.reportError = exports.isPlainObject = exports.mapKeys = exports.mapValues = exports.mapObject = exports.pick = exports.exclude = void 0;
exports.remap = exports.getIn = exports.defaults = exports.reverseObject = exports.newMacrotask = exports.awaitRecord = exports.reportError = exports.isPlainObject = exports.isObject = exports.mapKeys = exports.mapValues = exports.mapObject = exports.pick = exports.exclude = void 0;
const promise_assist_1 = require("promise-assist");

@@ -54,2 +54,18 @@ const chain_1 = require("./chain");

/**
* Checks if value is an object, e.g. a plain object, an array, a function,
* a regex, but not a primitive value.
*
* Common usage scenario:
* ```ts
* isObject(value) && value.foo === 'bar';
* // Instead of:
* typeof value === 'object' && value !== null && 'foo' in value && value.foo === 'bar';
* ```
*/
function isObject(value) {
const type = typeof value;
return value !== null && (type === 'object' || type === 'function');
}
exports.isObject = isObject;
/**
* Checks that value is a POJO

@@ -56,0 +72,0 @@ */

@@ -13,2 +13,14 @@ /**

/**
* Creates an error with error code. Helpful when `instanceof` can't be used
* because the error was serialized and then deserialized.
* @example
* ```ts
* try {
* throw new ErrorWithCode('message', { code: 'ENOENT' });
* } catch (error) {
* if (getErrorCode(toError(error)) === 'ENOENT') {
* // ...
* }
* }
* ```
*/

@@ -44,3 +56,9 @@ export declare class ErrorWithCode extends Error {

};
/**
* Checks if the `error` is an object compatible with the Error interface; that is,
* it has properties 'name' and 'message' of type string. The object could be an
* instance of an Error, or it could be some other kind of object that has these
* properties.
*/
export declare function isErrorLikeObject(error: unknown): error is Error;
//# sourceMappingURL=errors.d.ts.map

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

import { isPlainObject } from './objects';
import { isObject } from './objects';
/**

@@ -16,2 +16,14 @@ * Convert any kind of value to an error instance. Unless the value is already

/**
* Creates an error with error code. Helpful when `instanceof` can't be used
* because the error was serialized and then deserialized.
* @example
* ```ts
* try {
* throw new ErrorWithCode('message', { code: 'ENOENT' });
* } catch (error) {
* if (getErrorCode(toError(error)) === 'ENOENT') {
* // ...
* }
* }
* ```
*/

@@ -61,7 +73,11 @@ export class ErrorWithCode extends Error {

}
/**
* Checks if the `error` is an object compatible with the Error interface; that is,
* it has properties 'name' and 'message' of type string. The object could be an
* instance of an Error, or it could be some other kind of object that has these
* properties.
*/
export function isErrorLikeObject(error) {
return (isPlainObject(error) &&
typeof error.name === 'string' &&
typeof error.message === 'string');
return isObject(error) && typeof error.name === 'string' && typeof error.message === 'string';
}
//# sourceMappingURL=errors.js.map

@@ -28,2 +28,14 @@ import type { UnionToIntersection } from './types';

/**
* Checks if value is an object, e.g. a plain object, an array, a function,
* a regex, but not a primitive value.
*
* Common usage scenario:
* ```ts
* isObject(value) && value.foo === 'bar';
* // Instead of:
* typeof value === 'object' && value !== null && 'foo' in value && value.foo === 'bar';
* ```
*/
export declare function isObject(value: unknown): value is Readonly<Record<string | number | symbol, unknown>>;
/**
* Checks that value is a POJO

@@ -30,0 +42,0 @@ */

@@ -46,2 +46,17 @@ import { sleep } from 'promise-assist';

/**
* Checks if value is an object, e.g. a plain object, an array, a function,
* a regex, but not a primitive value.
*
* Common usage scenario:
* ```ts
* isObject(value) && value.foo === 'bar';
* // Instead of:
* typeof value === 'object' && value !== null && 'foo' in value && value.foo === 'bar';
* ```
*/
export function isObject(value) {
const type = typeof value;
return value !== null && (type === 'object' || type === 'function');
}
/**
* Checks that value is a POJO

@@ -48,0 +63,0 @@ */

2

package.json
{
"name": "@wixc3/common",
"version": "13.0.1",
"version": "13.1.0",
"description": "Common utils, usable in all environments",

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

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

import { isPlainObject } from './objects';
import { isObject } from './objects';

@@ -19,2 +19,14 @@ /**

/**
* Creates an error with error code. Helpful when `instanceof` can't be used
* because the error was serialized and then deserialized.
* @example
* ```ts
* try {
* throw new ErrorWithCode('message', { code: 'ENOENT' });
* } catch (error) {
* if (getErrorCode(toError(error)) === 'ENOENT') {
* // ...
* }
* }
* ```
*/

@@ -70,8 +82,10 @@ export class ErrorWithCode extends Error {

/**
* Checks if the `error` is an object compatible with the Error interface; that is,
* it has properties 'name' and 'message' of type string. The object could be an
* instance of an Error, or it could be some other kind of object that has these
* properties.
*/
export function isErrorLikeObject(error: unknown): error is Error {
return (
isPlainObject(error) &&
typeof (error as { name?: string }).name === 'string' &&
typeof (error as { message?: string }).message === 'string'
);
return isObject(error) && typeof error.name === 'string' && typeof error.message === 'string';
}

@@ -62,2 +62,18 @@ import { sleep } from 'promise-assist';

/**
* Checks if value is an object, e.g. a plain object, an array, a function,
* a regex, but not a primitive value.
*
* Common usage scenario:
* ```ts
* isObject(value) && value.foo === 'bar';
* // Instead of:
* typeof value === 'object' && value !== null && 'foo' in value && value.foo === 'bar';
* ```
*/
export function isObject(value: unknown): value is Readonly<Record<string | number | symbol, unknown>> {
const type = typeof value;
return value !== null && (type === 'object' || type === 'function');
}
/**
* Checks that value is a POJO

@@ -64,0 +80,0 @@ */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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