@maskito/core
Advanced tools
Comparing version 0.16.0 to 1.0.0
const MASKITO_DEFAULT_ELEMENT_PREDICATE = e => e.querySelector('input,textarea') || e; | ||
function identity(x) { | ||
return x; | ||
} | ||
const MASKITO_DEFAULT_OPTIONS = { | ||
mask: /^.*$/, | ||
preprocessor: identity, | ||
postprocessor: identity, | ||
preprocessors: [], | ||
@@ -493,7 +487,6 @@ postprocessors: [], | ||
/** | ||
* @deprecated Use property `preprocessors` / `postprocessors` from `MaskitoOptions` | ||
* @internal | ||
*/ | ||
function maskitoPipe(...processors) { | ||
return (initialData, ...readonlyArgs) => processors.filter(x => !!x).reduce((data, fn) => Object.assign(Object.assign({}, data), fn(data, ...readonlyArgs)), initialData); | ||
function maskitoPipe(processors = []) { | ||
return (initialData, ...readonlyArgs) => processors.reduce((data, fn) => Object.assign(Object.assign({}, data), fn(data, ...readonlyArgs)), initialData); | ||
} | ||
@@ -503,4 +496,4 @@ | ||
const options = Object.assign(Object.assign({}, MASKITO_DEFAULT_OPTIONS), maskitoOptions); | ||
const preprocessor = maskitoPipe(options.preprocessor, ...options.preprocessors); | ||
const postprocessor = maskitoPipe(options.postprocessor, ...options.postprocessors); | ||
const preprocessor = maskitoPipe(options.preprocessors); | ||
const postprocessor = maskitoPipe(options.postprocessors); | ||
const initialElementState = typeof valueOrState === 'string' ? { | ||
@@ -535,4 +528,4 @@ value: valueOrState, | ||
this.options = Object.assign(Object.assign({}, MASKITO_DEFAULT_OPTIONS), this.maskitoOptions); | ||
this.preprocessor = maskitoPipe(this.options.preprocessor, ...this.options.preprocessors); | ||
this.postprocessor = maskitoPipe(this.options.postprocessor, ...this.options.postprocessors); | ||
this.preprocessor = maskitoPipe(this.options.preprocessors); | ||
this.postprocessor = maskitoPipe(this.options.postprocessors); | ||
this.teardowns = this.options.plugins.map(plugin => plugin(this.element, this.options)); | ||
@@ -539,0 +532,0 @@ this.ensureValueFitsMask(); |
@@ -11,10 +11,4 @@ (function (global, factory) { | ||
function identity(x) { | ||
return x; | ||
} | ||
var MASKITO_DEFAULT_OPTIONS = { | ||
mask: /^.*$/, | ||
preprocessor: identity, | ||
postprocessor: identity, | ||
preprocessors: [], | ||
@@ -598,11 +592,8 @@ postprocessors: [], | ||
/** | ||
* @deprecated Use property `preprocessors` / `postprocessors` from `MaskitoOptions` | ||
* @internal | ||
*/ | ||
function maskitoPipe() { | ||
var processors = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
processors[_i] = arguments[_i]; | ||
function maskitoPipe(processors) { | ||
if (processors === void 0) { | ||
processors = []; | ||
} | ||
@@ -617,5 +608,3 @@ | ||
return processors.filter(function (x) { | ||
return !!x; | ||
}).reduce(function (data, fn) { | ||
return processors.reduce(function (data, fn) { | ||
return __assign(__assign({}, data), fn.apply(void 0, __spreadArray([data], readonlyArgs))); | ||
@@ -629,4 +618,4 @@ }, initialData); | ||
var preprocessor = maskitoPipe.apply(void 0, __spreadArray([options.preprocessor], options.preprocessors)); | ||
var postprocessor = maskitoPipe.apply(void 0, __spreadArray([options.postprocessor], options.postprocessors)); | ||
var preprocessor = maskitoPipe(options.preprocessors); | ||
var postprocessor = maskitoPipe(options.postprocessors); | ||
var initialElementState = typeof valueOrState === 'string' ? { | ||
@@ -665,4 +654,4 @@ value: valueOrState, | ||
_this.options = __assign(__assign({}, MASKITO_DEFAULT_OPTIONS), _this.maskitoOptions); | ||
_this.preprocessor = maskitoPipe.apply(void 0, __spreadArray([_this.options.preprocessor], _this.options.preprocessors)); | ||
_this.postprocessor = maskitoPipe.apply(void 0, __spreadArray([_this.options.postprocessor], _this.options.postprocessors)); | ||
_this.preprocessor = maskitoPipe(_this.options.preprocessors); | ||
_this.postprocessor = maskitoPipe(_this.options.postprocessors); | ||
_this.teardowns = _this.options.plugins.map(function (plugin) { | ||
@@ -669,0 +658,0 @@ return plugin(_this.element, _this.options); |
@@ -7,13 +7,3 @@ import { ElementState } from './element-state'; | ||
readonly mask: MaskitoMask; | ||
/** | ||
* @deprecated Use property {@link preprocessors} | ||
* TODO: delete it in 1.x.x | ||
*/ | ||
readonly preprocessor?: MaskitoPreprocessor; | ||
readonly preprocessors?: readonly MaskitoPreprocessor[]; | ||
/** | ||
* @deprecated Use property {@link postprocessors} | ||
* TODO: delete it in 1.x.x | ||
*/ | ||
readonly postprocessor?: MaskitoPostprocessor; | ||
readonly postprocessors?: readonly MaskitoPostprocessor[]; | ||
@@ -20,0 +10,0 @@ readonly plugins?: readonly MaskitoPlugin[]; |
@@ -9,5 +9,4 @@ export * from './dom/event-listener'; | ||
export * from './get-word-selection'; | ||
export * from './identity'; | ||
export * from './pipe'; | ||
export * from './transform'; | ||
//# sourceMappingURL=index.d.ts.map |
import { MaskitoPostprocessor, MaskitoPreprocessor } from '../types'; | ||
/** | ||
* @deprecated Use property `preprocessors` from `MaskitoOptions` | ||
* @internal | ||
*/ | ||
export declare function maskitoPipe(...processors: ReadonlyArray<MaskitoPreprocessor | null | undefined>): MaskitoPreprocessor; | ||
export declare function maskitoPipe(processors?: readonly MaskitoPreprocessor[]): MaskitoPreprocessor; | ||
/** | ||
* @deprecated Use property `postprocessors` from `MaskitoOptions` | ||
* @internal | ||
*/ | ||
export declare function maskitoPipe(...processors: ReadonlyArray<MaskitoPostprocessor | null | undefined>): MaskitoPostprocessor; | ||
export declare function maskitoPipe(processors?: readonly MaskitoPostprocessor[]): MaskitoPostprocessor; | ||
//# sourceMappingURL=pipe.d.ts.map |
{ | ||
"name": "@maskito/core", | ||
"version": "0.16.0", | ||
"version": "1.0.0", | ||
"description": "The main zero-dependency and framework-agnostic Maskito's package to create an input mask", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
84044
78
1676