@appliedblockchain/parser-combinators
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -5,3 +5,5 @@ // @flow | ||
const exhaustiveResult /*: <R>(string => [string, R]) => R */ = /*:: <R> */ | ||
/*:: import type { Parser } from './types/parser' */ | ||
const exhaustiveResult /*: <R>(Parser<R>) => (string => R) */ = /*:: <R> */ | ||
(a) => | ||
@@ -8,0 +10,0 @@ input => { |
{ | ||
"name": "@appliedblockchain/parser-combinators", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Monadic parser combinators.", | ||
@@ -20,4 +20,4 @@ "main": "index.js", | ||
"eslint": "6.8.0", | ||
"flow-bin": "0.120.1", | ||
"jest": "25.1.0" | ||
"flow-bin": "0.122.0", | ||
"jest": "25.2.7" | ||
}, | ||
@@ -24,0 +24,0 @@ "eslintConfig": { |
// @flow | ||
/*:: import type { Parser as P } from './types/Parser' */ | ||
const { inspect } = require('util') | ||
const Invalid = require('./invalid') | ||
const whileChar /*: (string => boolean) => P<string> */ = | ||
f => | ||
/*:: import type { Parser } from './types/parser' */ | ||
const whileChar /*: (string, min?: number) => Parser<string> */ = | ||
(chars, min = 0) => | ||
input => { | ||
let i | ||
for (i = 0; i < input.length; i++) { | ||
if (!f(input[0])) { | ||
if (!chars.includes(input[i])) { | ||
break | ||
} | ||
} | ||
if (i < min) { | ||
throw new Invalid(`Expected ${min} minimum characters passing predicate, character ${inspect(input[i])} didn't pass.`) | ||
} | ||
return [ input.slice(i), input.slice(0, i) ] | ||
@@ -15,0 +21,0 @@ } |
@@ -6,4 +6,4 @@ // @flow | ||
const ws0 = | ||
whileChar(_ => _ === '\x20' || _ === '\x0a' || _ === '\x0d' || _ === '\x09') | ||
whileChar(' \t\r\n') | ||
module.exports = ws0 |
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
74971
44
1945