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

optimal

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimal - npm Package Compare versions

Comparing version 3.2.1 to 3.3.0

.github/FUNDING.yml

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 3.3.0
#### ⚙️ Types
- Refined types and replaced `any` with `unknown`.
## 3.2.1 - 2019-04-22

@@ -2,0 +8,0 @@

5

lib/Builder.d.ts
import { SupportedType, CheckerCallback, CustomCallback, OptimalOptions, FuncOf } from './types';
export interface TemporalStruct {
[key: string]: unknown;
}
export interface Check {

@@ -53,3 +56,3 @@ args: unknown[];

*/
isOptionalDefault(value: any): boolean;
isOptionalDefault(value: unknown): boolean;
/**

@@ -56,0 +59,0 @@ * Return the current key from a path.

4

lib/index.js

@@ -87,4 +87,6 @@ "use strict";

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -91,0 +93,0 @@

import Builder from './Builder';
export declare type Constructor<T> = (new (...args: any[]) => T) | (Function & {
export declare type Constructor<T> = (new (...args: unknown[]) => T) | (Function & {
prototype: T;

@@ -16,4 +16,4 @@ });

export declare function instance<T = Function>(refClass?: Constructor<T> | null, loose?: boolean): InstanceBuilder<T>;
export declare function builder<T = any>(): InstanceBuilder<Builder<T>>;
export declare function builder<T = unknown>(): InstanceBuilder<Builder<T>>;
export declare function regex(): InstanceBuilder<RegExp>;
export declare function date(): InstanceBuilder<Date>;

@@ -15,2 +15,2 @@ import Builder from './Builder';

export declare function object<T = unknown>(contents?: Builder<T> | null, defaultValue?: ObjectOf<T>): ObjectBuilder<T>;
export declare function blueprint<T = any>(defaultValue?: ObjectOf<Builder<T>>): ObjectBuilder<Builder<T>>;
export declare function blueprint<T = unknown>(defaultValue?: ObjectOf<Builder<T>>): ObjectBuilder<Builder<T>>;

@@ -8,4 +8,4 @@ import Builder from './Builder';

exact(): this;
runChecks(path: string, initialValue: Partial<Shape> | undefined, struct: object, options?: OptimalOptions): any;
runChecks(path: string, initialValue: Shape | undefined, struct: object, options?: OptimalOptions): Required<Shape>;
}
export declare function shape<P extends object>(contents: Blueprint<P>): ShapeBuilder<P>;

@@ -10,3 +10,3 @@ import Builder from './Builder';

};
export declare type CheckerCallback = (path: string, value: any, ...args: any[]) => void;
export declare type CheckerCallback = (path: string, value: any, ...args: any[]) => unknown;
export declare type CustomCallback<T> = (value: T, struct: object) => void;

@@ -13,0 +13,0 @@ export interface OptimalOptions {

import Builder from './Builder';
export default class UnionBuilder<T = unknown> extends Builder<T> {
builders: Builder<unknown>[];
constructor(builders: Builder<unknown>[], defaultValue: any);
checkUnions(path: string, value: any, builders: Builder<unknown>[]): any;
constructor(builders: Builder<unknown>[], defaultValue: T);
checkUnions(path: string, value: unknown, builders: Builder<unknown>[]): unknown;
/**

@@ -11,2 +11,2 @@ * Return the type name using pipe syntax.

}
export declare function union<T = unknown>(builders: Builder<unknown>[], defaultValue: any): UnionBuilder<T>;
export declare function union<T = unknown>(builders: Builder<unknown>[], defaultValue: T): UnionBuilder<T>;
{
"name": "optimal",
"version": "3.2.1",
"version": "3.3.0",
"description": "A system for building and validating defined object structures.",

@@ -9,2 +9,3 @@ "main": "./lib/index.js",

"scripts": {
"prepare": "beemo create-config --silent",
"build": "beemo run-script build",

@@ -16,3 +17,3 @@ "coverage": "yarn run jest --coverage",

"prerelease": "yarn test && yarn run build",
"release": "np --yolo --no-yarn",
"release": "npx np --yolo --no-yarn",
"pretest": "yarn run type",

@@ -48,3 +49,5 @@ "test": "yarn run jest",

"devDependencies": {
"@milesj/build-tools": "^0.43.1"
"@milesj/build-tools": "^0.60.5",
"@types/node": "^12.12.14",
"conventional-changelog-beemo": "^1.6.0"
},

@@ -59,7 +62,16 @@ "beemo": {

"typescript"
]
],
"eslint": {
"rules": {
"default-param-last": "off"
}
}
},
"browserslist": [
"ie 11"
]
],
"funding": {
"type": "ko-fi",
"url": "https://ko-fi.com/milesjohnson"
}
}
# Optimal
[![Build Status](https://travis-ci.org/milesj/optimal.svg?branch=master)](https://travis-ci.org/milesj/optimal)
[![Build Status](https://github.com/milesj/optimal/workflows/Build/badge.svg)](https://github.com/milesj/optimal/actions?query=branch%3Amaster)
[![npm version](https://badge.fury.io/js/optimal.svg)](https://www.npmjs.com/package/optimal)

@@ -5,0 +5,0 @@ [![npm deps](https://david-dm.org/milesj/optimal.svg)](https://www.npmjs.com/package/optimal)

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