@produck/mold
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "@produck/mold", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "For helping to create a final options from a defined specification.", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "63ad64c043dcf30998bb3cb91508120329c12e4f" | ||
"gitHead": "2b0a90f4da6d0891dca9bd6ca6ce457bc663e30b" | ||
} |
@@ -6,10 +6,10 @@ # @produck/mold | ||
[![npm](https://img.shields.io/npm/dw/@produck/mold)](https://www.npmjs.com/package/@produck/mold) | ||
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=flat-square)](https://lerna.js.org/) | ||
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/) | ||
[![NPM](https://img.shields.io/npm/l/@produck/mold)](https://opensource.org/licenses/MIT) | ||
A tool module for defining data type schemas to a normalize function. It has been published as a "[Dual CommonJS/ES module](https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#dual-commonjses-module-packages)" package but ESM first. It is very simple, flexible and extensible. | ||
A tool module for defining data type schemas to a normalize function. It published as a "[Dual CommonJS/ES module](https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#dual-commonjses-module-packages)" package but ESM first. It is very simple, flexible and extensible. | ||
There is also some default "Catcher" for helping to throw a "[TypeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)" with good readability messages. It can be also defined a completely custom catcher to handle the cause if a bad value provided. | ||
There is also some default "Catcher". It is helping to throw a "[TypeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)" with good readability messages. It can be also defined a completely custom catcher to handle the cause if a bad value provided. | ||
It can work in "node.js" and browsers. It is also very friendly with "tree shaking", using "[Rollup](https://rollupjs.org/guide/en/)" so try ESM firstly. | ||
It can work in "node.js" and browsers. It is also very friendly with "tree shaking", using "[Rollup](https://rollupjs.org/guide/en/)" so try ESM. | ||
@@ -58,2 +58,6 @@ ## Installation | ||
} from '@produck/mold'; | ||
// Or | ||
import * as Mold from '@produck/mold'; | ||
// Your code... | ||
``` | ||
@@ -69,2 +73,6 @@ As CommonJS, | ||
} = require('@produck/mold'); | ||
// Or | ||
const Mold = require('@produck/mold'); | ||
// Your code... | ||
``` | ||
@@ -147,4 +155,5 @@ ### Creating a normalize() from schema | ||
``` | ||
## Best Practices | ||
## License | ||
[MIT](https://github.com/produck/mold/blob/main/LICENSE) |
@@ -65,1 +65,12 @@ import { Schema } from './schema'; | ||
export const Normalizer: NormalizerConstructor; | ||
export namespace Utils { | ||
const throwError: (role: string, expected: string) => never; | ||
class MoldCause { | ||
constructor(value: any); | ||
setType(typeName: string): this; | ||
append(detail: object): this; | ||
throw(next?: Error | MoldCause): never; | ||
} | ||
} |
import { Schema } from './schema'; | ||
export const Any: (defaultValue?: any) => Schema<any>; | ||
export const Constant: <Type>( | ||
@@ -4,0 +6,0 @@ value: Type, |
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
58515
1629
155