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

@maskito/kit

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maskito/kit - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

src/lib/masks/number/processors/zero-precision-preprocessor.d.ts

4

package.json
{
"name": "@maskito/kit",
"version": "0.5.0",
"version": "0.6.0",
"description": "The optional framework-agnostic Maskito's package with ready-to-use masks",

@@ -33,3 +33,3 @@ "keywords": [

"peerDependencies": {
"@maskito/core": "^0.5.0"
"@maskito/core": "^0.6.0"
},

@@ -36,0 +36,0 @@ "main": "./src/index.js",

import { maskitoPipe } from '@maskito/core';
import { CHAR_EM_DASH, CHAR_EN_DASH, CHAR_HYPHEN, CHAR_MINUS, CHAR_NO_BREAK_SPACE, } from '../../constants';
import { createDecimalZeroPaddingPostprocessor, createLeadingZeroesValidationPostprocessor, createMaxValidationPostprocessor, createNotEmptyIntegerPartPreprocessor, createPseudoCharactersPreprocessor, createSeparatorDeletionPreprocessor, createThousandSeparatorPostprocessor, } from './processors';
import { createDecimalZeroPaddingPostprocessor, createLeadingZeroesValidationPostprocessor, createMaxValidationPostprocessor, createNotEmptyIntegerPartPreprocessor, createPseudoCharactersPreprocessor, createSeparatorDeletionPreprocessor, createThousandSeparatorPostprocessor, createZeroPrecisionPreprocessor, } from './processors';
import { generateMaskExpression, getDefaultPseudoSeparators } from './utils';
export function maskitoNumberOptionsGenerator({ max = Number.MAX_SAFE_INTEGER, isNegativeAllowed = true, precision = 0, thousandSeparator = CHAR_NO_BREAK_SPACE, decimalSeparator = ',', decimalPseudoSeparators = getDefaultPseudoSeparators({
decimalSeparator,
thousandSeparator,
}), decimalZeroPadding = false, } = {}) {
export function maskitoNumberOptionsGenerator({ max = Number.MAX_SAFE_INTEGER, isNegativeAllowed = true, precision = 0, thousandSeparator = CHAR_NO_BREAK_SPACE, decimalSeparator = '.', decimalPseudoSeparators = getDefaultPseudoSeparators(decimalSeparator, thousandSeparator), decimalZeroPadding = false, } = {}) {
const pseudoMinuses = [CHAR_HYPHEN, CHAR_EN_DASH, CHAR_EM_DASH].filter(char => char !== thousandSeparator && char !== decimalSeparator);

@@ -21,3 +18,3 @@ return {

thousandSeparator,
})),
}), createZeroPrecisionPreprocessor(precision, decimalSeparator)),
postprocessor: maskitoPipe(createLeadingZeroesValidationPostprocessor(decimalSeparator), createMaxValidationPostprocessor({ decimalSeparator, max }), createThousandSeparatorPostprocessor({ decimalSeparator, thousandSeparator }), createDecimalZeroPaddingPostprocessor({

@@ -24,0 +21,0 @@ decimalSeparator,

@@ -8,2 +8,3 @@ export * from './decimal-zero-padding-postprocessor';

export * from './thousand-separator-postprocessor';
export * from './zero-precision-preprocessor';
//# sourceMappingURL=index.d.ts.map

@@ -8,2 +8,3 @@ export * from './decimal-zero-padding-postprocessor';

export * from './thousand-separator-postprocessor';
export * from './zero-precision-preprocessor';
//# sourceMappingURL=index.js.map

@@ -1,5 +0,2 @@

export declare function getDefaultPseudoSeparators({ decimalSeparator, thousandSeparator, }: {
decimalSeparator: string;
thousandSeparator: string;
}): string[];
export declare function getDefaultPseudoSeparators(decimalSeparator: string, thousandSeparator: string): string[];
//# sourceMappingURL=get-default-pseudo-separators.d.ts.map

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

export function getDefaultPseudoSeparators({ decimalSeparator, thousandSeparator, }) {
if (decimalSeparator === ',' || decimalSeparator === '.') {
return ['.', ',', 'б', 'ю'].filter(char => char !== thousandSeparator && char !== decimalSeparator);
}
return [];
export function getDefaultPseudoSeparators(decimalSeparator, thousandSeparator) {
return decimalSeparator === ',' || decimalSeparator === '.'
? ['.', ',', 'б', 'ю'].filter(char => char !== thousandSeparator && char !== decimalSeparator)
: [];
}
//# sourceMappingURL=get-default-pseudo-separators.js.map

@@ -0,6 +1,9 @@

import { CHAR_EM_DASH, CHAR_EN_DASH, CHAR_HYPHEN, CHAR_MINUS } from '../../../constants';
export function maskitoParseNumber(maskedNumber, decimalSeparator = '.') {
return Number(maskedNumber
.replace(new RegExp(`[^\\d\\${decimalSeparator}]`, 'g'), '')
.replace(decimalSeparator, '.'));
const negativeSign = maskedNumber.match(new RegExp(`^[${CHAR_MINUS}\\${CHAR_HYPHEN}${CHAR_EN_DASH}${CHAR_EM_DASH}]`));
return Number((negativeSign ? CHAR_HYPHEN : '') +
maskedNumber
.replace(new RegExp(`[^\\d\\${decimalSeparator}]`, 'g'), '')
.replace(decimalSeparator, '.'));
}
//# sourceMappingURL=parse-number.js.map

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

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

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