New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flat-file-parser

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat-file-parser - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

lib/helper.js

2

lib/lineParser.js

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

"use strict";const LineParser=function(e,n,r){let t,i,o,s,c={};return c.process=(e,n,r,s)=>i>0&&t++>=i?null:{data:o.call(n,e,n,r,s),completed:i>0&&t>=i},c.callback=(e,n,r,t,i)=>{if(s)return s.call(r,e,n,r,t,i)},((e,n,r)=>{if(c[Symbol.toStringTag]="LineParser",t=0,"function"!=typeof e)throw"lineProcessor is a function parameter. definition: function lineProcessor<Any>(line: String, currentProcessIndex: Int, lineNumber: Int): <Any>";return o=e,i=isNaN(n)?0:n>=0?n:0,r&&"function"==typeof r&&(s=r),c})(e,n,r)};module.exports={LineParser};
"use strict";const{sanityInt}=require("./helper"),LineParser=function(n,e,r,t=!1){let o,i,l,s,a={},c=!1;return a.process=(n,e,r,t)=>i>0&&o++>=i?null:{data:l.call(e,n,e,r,t),completed:i>0&&o>=i},a.callback=(n,e,r,t,o)=>{if(s)return c?s.call(r,r,t,o):s.call(r,n,e,r,t,o)},a.isLoop=()=>c,a.loopCount=()=>c?i:null,a.reLoop=()=>c?s:null,((n,e,r,t)=>{if(a[Symbol.toStringTag]="LineParser",o=0,"function"!=typeof n)throw"lineProcessor is a function parameter. definition: function lineProcessor<Any>(line: String, currentProcessIndex: Int, lineNumber: Int): <Any>";return l=n,i=sanityInt(e),r&&"function"==typeof r&&(s=r),c=t,a})(n,e,r,t)};module.exports={LineParser};

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

"use strict";const fs=require("fs"),readline=require("readline"),{once}=require("events"),{LineParser}=require("./lineParser"),FlatFileParser=function(){let e={},r=null,s=!1,n=!1,l=0,t=0,i=[];const _ensureOpened=()=>{if(!s||null==r)throw"No file has been opened for parsing. Please use open() before using it"};return e.open=n=>(r=fs.createReadStream(n),s=!0,e),e.next=(r,s,a)=>(_ensureOpened(),n?i.splice(++t+l,0,LineParser(r,s,a)):i.push(LineParser(r,s,a)),e),e.skip=(r,s)=>{if((isNaN(r)?0:r>=0?r:0)<=0)throw"Please set the noOfLines to skip. It should be a positive integer.";return e.next((e=>e),r,s),e},e.process=async()=>{_ensureOpened(),n=!0;try{let s=0;const n=readline.createInterface({input:r});n.on("line",((r,a)=>{if(i.length>l){const n=i[l],a=n.process(r,e,l,s);n.callback(a.data,r,e,l,s);a.completed&&(t=0,l++)}else n.close();s++})).on("close",(()=>{e.done(),n.removeAllListeners()})),await once(n,"close")}catch(e){console.error(e)}return e},e.done=()=>(null!=r&&r.destroy(),r=null,s=!1,i.splice(0),l=0,t=0,n=!1,e),e[Symbol.toStringTag]="FlatFileParser",e};module.exports={FlatFileParser,flatFileParser:FlatFileParser()};
"use strict";const fs=require("fs"),readline=require("readline"),{once}=require("events"),{LineParser}=require("./lineParser"),{sanityInt}=require("./helper"),FlatFileParser=function(){let e={},r=null,t=!1,n=!1,l=0,s=0,o=[];const _ensureOpened=()=>{if(!t||null==r)throw"No file has been opened for parsing. Please use open() before using it"};e.open=n=>(r=fs.createReadStream(n),t=!0,e);const _next=(r,t,i,a=!1)=>(_ensureOpened(),n?o.splice(++s+l,0,LineParser(r,t,i,a)):o.push(LineParser(r,t,i,a)),e);return e.next=(e,r,t)=>_next(e,r,t),e.loop=(e,r)=>_next((()=>null),r,e,!0),e.skip=(e,r)=>{if(sanityInt(e)<=0)throw"Must set the noOfLines to skip. It should be a positive integer";return _next((e=>e),e,r)},e.process=async()=>{_ensureOpened(),n=!0;try{let t=0;const n=readline.createInterface({input:r}),_processLine=r=>{if(o.length>l){const n=o[l];let i={data:null,completed:!1};const a=n.isLoop();a||(i=n.process(r,e,l,t));n.callback(i.data,r,e,l,t);if(a){let r=n.loopCount();1!=r&&e.loop(n.reLoop(),r-1),i.completed=!0}i.completed&&(s=0,l++),a&&_processLine(r)}else n.close()};n.on("line",(e=>{_processLine(e),t++})).on("close",(()=>{e.done(),n.removeAllListeners()})),await once(n,"close")}catch(e){console.error(e)}return e},e.done=()=>(null!=r&&r.destroy(),r=null,t=!1,o.splice(0),l=0,s=0,n=!1,e),e[Symbol.toStringTag]="FlatFileParser",e};module.exports={FlatFileParser,flatFileParser:FlatFileParser()};
{
"name": "flat-file-parser",
"version": "0.4.0",
"version": "0.5.0",
"description": "some Flat File Parser",

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

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