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

schemaglobin

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schemaglobin - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

dist/helpers/array.d.ts

3

.eslintrc.json
{
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
"parser": "@typescript-eslint/parser",
"parserOptions": {

@@ -68,2 +68,3 @@ "sourceType": "module",

"prefer-template": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-empty-function": 0,

@@ -70,0 +71,0 @@ "@typescript-eslint/no-unused-vars": 0,

@@ -15,2 +15,3 @@ export * from "./Schema";

export * from "./schemas/UrlSchema";
export * from "./helpers/array";
export * from "./helpers/date";

@@ -20,3 +21,4 @@ export * from "./helpers/distance";

export * from "./helpers/number";
export * from "./helpers/object";
export * from "./helpers/schema";
export * from "./helpers/string";

@@ -30,2 +30,3 @@ "use strict";

// Export helpers.
__exportStar(require("./helpers/array"), exports);
__exportStar(require("./helpers/date"), exports);

@@ -35,3 +36,4 @@ __exportStar(require("./helpers/distance"), exports);

__exportStar(require("./helpers/number"), exports);
__exportStar(require("./helpers/object"), exports);
__exportStar(require("./helpers/schema"), exports);
__exportStar(require("./helpers/string"), exports);

@@ -7,9 +7,9 @@ /** Helper type that allows `null` if `R` (required) is false. */

export declare type EmptyIfOptional<R extends boolean> = R extends true ? never : "";
/** Like `Partial` but works recursively on an object. */
export declare type DeepPartial<O extends {}> = {
[K in keyof O]?: DeepPartial<O[K]>;
/** An object whose properties are unknown. */
export declare type UnknownObject = Record<string, unknown>;
/** An object with no properties. */
export declare type EmptyObject = Record<string, never>;
/** Deep partial: Like `Partial` but works recursively on objects. */
export declare type DeepPartial<T extends UnknownObject = UnknownObject> = T | {
[K in keyof T]?: T[K] extends UnknownObject ? DeepPartial<T[K]> : T[K];
};
/** Object with only string keys and unknown values. */
export declare type UnknownObject = {
[key: string]: unknown;
};
{
"name": "schemaglobin",
"description": "Validate user-entered data.",
"version": "4.1.0",
"version": "4.2.0",
"repository": "https://github.com/dhoulb/schemaglobin",

@@ -29,14 +29,14 @@ "author": "Dave Houlbrooke <dave@shax.com>",

"devDependencies": {
"@types/jest": "^25.2.3",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"eslint": "^7.0.0",
"@types/jest": "^26.0.0",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/parser": "^3.3.0",
"eslint": "^7.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"ts-jest": "^26.0.0",
"typescript": "^3.9.3"
"ts-jest": "^26.1.0",
"typescript": "^3.9.5"
}
}
/** Things that can be converted to dates. */
export type PossibleDate = Date | number | string;
export const makeDate = (date: PossibleDate) => (date instanceof Date ? date : new Date(date));
export const makeDate = (date: PossibleDate): Date => (date instanceof Date ? date : new Date(date));

@@ -122,2 +122,2 @@ /** Convert a `Date()` instance to a YMD string like "2015-09-12" */

/** Format a date in the browser locale. */
export const formatDate = (date: PossibleDate) => makeDate(date).toLocaleString();
export const formatDate = (date: PossibleDate): string => makeDate(date).toLocaleString();

@@ -11,15 +11,20 @@ import { formatNumber } from "./number";

const data: {
[K in DistanceUnit]: {
millimeter?: number;
centimeter?: number;
meter: number; // Meters are the base unit and are required.
kilometer?: number;
mile?: number;
yard?: number;
foot?: number;
inch?: number;
regex: RegExp;
short: string;
precision?: number;
m?: DistanceUnit;
readonly [K in DistanceUnit]: {
// Meters are required (all conversions go through meters if a specific number isn't provided).
readonly meter: number;
// All other units are optional.
readonly millimeter?: number;
readonly centimeter?: number;
readonly kilometer?: number;
readonly mile?: number;
readonly yard?: number;
readonly foot?: number;
readonly inch?: number;
readonly regex: RegExp;
// Short suffix.
readonly short: string;
// Default number of decimal places.
readonly precision?: number;
// If e.g. `10m` is specified, does `m` mean `mile` or `meter`.
readonly m?: DistanceUnit;
};

@@ -107,3 +112,3 @@ } = {

/** Format a distance. */
export const formatDistance = (num: number, unit: DistanceUnit = "meter", precision = data[unit].precision || 0) =>
export const formatDistance = (num: number, unit: DistanceUnit = "meter", precision = data[unit].precision || 0): string =>
`${formatNumber(num, precision)} ${data[unit].short}`;

@@ -20,2 +20,3 @@ // Export schema.

// Export helpers.
export * from "./helpers/array";
export * from "./helpers/date";

@@ -25,3 +26,4 @@ export * from "./helpers/distance";

export * from "./helpers/number";
export * from "./helpers/object";
export * from "./helpers/schema";
export * from "./helpers/string";

@@ -10,6 +10,9 @@ /** Helper type that allows `null` if `R` (required) is false. */

/** Like `Partial` but works recursively on an object. */
export type DeepPartial<O extends {}> = { [K in keyof O]?: DeepPartial<O[K]> };
/** An object whose properties are unknown. */
export type UnknownObject = Record<string, unknown>;
/** Object with only string keys and unknown values. */
export type UnknownObject = { [key: string]: unknown };
/** An object with no properties. */
export type EmptyObject = Record<string, never>;
/** Deep partial: Like `Partial` but works recursively on objects. */
export type DeepPartial<T extends UnknownObject = UnknownObject> = T | { [K in keyof T]?: T[K] extends UnknownObject ? DeepPartial<T[K]> : T[K] };
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"target": "es2019",
"declaration": true,

@@ -6,0 +6,0 @@ "esModuleInterop": true,

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