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

@produck/mold

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@produck/mold

For helping to create a final options from a defined specification.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
78
increased by500%
Maintainers
2
Weekly downloads
 
Created
Source

mold

TODO: description

Usage

import { S, C, P, Normalizer, Circular } from '@produck/mold';
/**
 * S = Simplex { Object, Array, Tuple, Value }
 * C = Compound { Not, And, Or, If }
 * P = Preset { Constant, Enum, Null, NotNull, Instance, Number, String, ... }
 */

const Object = S.Object({
	c: P.Constant(1),
	a: S.Object({
		b: P.String('foo'),
		c: P.Boolean(true)
	}),
	l: S.Array(S.Object({
		s: P.String('')
	})),
	d: S.Object({}),
	e: P.OrNull(P.Symbol()),
	route: Circular(schema => S.Object({
		name: P.String(),
		next: schema,
		previous: schema
	})),
	D: P.Instance(Date),
	point: S.Tuple([P.Number(0), P.Number(0), P.String('baz')]),
	port: P.Port(80),
	p: P.StringPattern(/[a-f0-9]+/)('9f'),
	l: P.StringLength(5)('33333'),
	m5: P.IntegerMultipleOf(5)(10)
});

const normalize = Normalizer(Object);

try {
	const finalOptions = normalize({
		c: 1,
		route: {
			name: 'a',
			next: {
				name: 'b',
				previous: null,
				next: {
				}
			},
			previous: null
		},
		e: null,
		D: new Date(),
		point: [0],
	});

	console.log(finalOptions);
} catch (error) {
	console.log(error);
}

Base

  • Schema

Native

  • ObjectSchema
  • ArraySchema
  • TupleSchema
  • ValueSchema

Proxy

  • CustomSchema
  • CircularSchema
  • NotSchema
  • AndSchema
  • OrSchema
  • BranchSchema

Preset

Normalizer

Keywords

FAQs

Package last updated on 18 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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