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

fixed-width-parser

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixed-width-parser - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

16

dist/FixedWidthParser.js

@@ -46,3 +46,3 @@ "use strict";

this.parseSegment = function (config, rawString, options) {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
var filteredString = filterCharacters_1.filterCharacters(rawString, _this.characterWhitelist);

@@ -74,12 +74,12 @@ // Strip out padding

}
return handleFalsyFallback_1.handleFalsyFallback(value, options.falsyFallback);
return handleFalsyFallback_1.handleFalsyFallback(value, (_c = config.falsyFallback) !== null && _c !== void 0 ? _c : options.falsyFallback);
}
case 'float': {
var decimalCount = (_c = config.decimalCount) !== null && _c !== void 0 ? _c : 2;
var decimalCount = (_d = config.decimalCount) !== null && _d !== void 0 ? _d : 2;
if (trimmedString.includes('.')) {
return handleFalsyFallback_1.handleFalsyFallback(Number(trimmedString), options.falsyFallback);
return handleFalsyFallback_1.handleFalsyFallback(Number(trimmedString), (_e = config.falsyFallback) !== null && _e !== void 0 ? _e : options.falsyFallback);
}
// Pad to original field width with 0's to ensure decimal can be injected
var stringToParse = trimmedString.padStart(config.width, '0');
return handleFalsyFallback_1.handleFalsyFallback(Number(splice_1.splice(stringToParse, '.', stringToParse.length - 1 - decimalCount)), options.falsyFallback);
return handleFalsyFallback_1.handleFalsyFallback(Number(splice_1.splice(stringToParse, '.', stringToParse.length - 1 - decimalCount)), (_f = config.falsyFallback) !== null && _f !== void 0 ? _f : options.falsyFallback);
}

@@ -94,3 +94,3 @@ case 'bool': {

_this.logger.warn("Failed to parse to boolean value. Falling back to " + options.falsyFallback + ".");
return handleFalsyFallback_1.handleFalsyFallback(false, options.falsyFallback);
return handleFalsyFallback_1.handleFalsyFallback(false, (_g = config.falsyFallback) !== null && _g !== void 0 ? _g : options.falsyFallback);
}

@@ -102,3 +102,3 @@ case 'date': {

}
var failValue = handleFalsyFallback_1.handleFalsyFallback(null, options.falsyFallback);
var failValue = handleFalsyFallback_1.handleFalsyFallback(null, (_h = config.falsyFallback) !== null && _h !== void 0 ? _h : options.falsyFallback);
_this.logger.warn("Failed to parse to date value. Falling back to " + failValue + ".");

@@ -114,3 +114,3 @@ return failValue;

// TODO: Find a good way to warn of untrimmed values as they may indicate a misconfiguration
return handleFalsyFallback_1.handleFalsyFallback(trimmedString, options.falsyFallback);
return handleFalsyFallback_1.handleFalsyFallback(trimmedString, (_j = config.falsyFallback) !== null && _j !== void 0 ? _j : options.falsyFallback);
}

@@ -117,0 +117,0 @@ }

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

import { FalsyFallback } from './IParseOptions';
export declare type ParseConfigInput = ParseConfig | IBaseParseConfig;

@@ -13,2 +14,3 @@ export declare type ParseConfig = ISkipParseConfig | IIntegerParseConfig | IStringParseConfig | IFloatParseConfig | IDateParseConfig | IBooleanParseConfig;

truncate?: boolean;
falsyFallback?: FalsyFallback;
}

@@ -15,0 +17,0 @@ export interface ISkipParseConfig extends IBaseParseConfig {

{
"name": "fixed-width-parser",
"version": "2.3.0",
"version": "2.4.0",
"description": "A fixed width data parser",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -74,2 +74,4 @@ # fixed-width-parser

* - `'passthrough'` = return the original falsy value
*
* If the value is not defined the default behavior is to passthrough
*/

@@ -151,2 +153,6 @@ falsyFallback: FalsyFallback;

truncate?: boolean;
// value to return if the parsed value is falsy
// this will override the more general behavior in parse options
// default: IParseOptions.falsyFallback value
falsyFallback?: 'undefined' | 'null' | 'passthrough'
}

@@ -153,0 +159,0 @@ ```

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