Comparing version 0.6.5 to 0.6.6
@@ -16,2 +16,7 @@ # Changelog | ||
# 0.6.6 | ||
- **New Feature** | ||
- add `lookAhead` and `takeUntil` to `Parser`, #24 (@IMax153) | ||
# 0.6.5 | ||
@@ -18,0 +23,0 @@ |
@@ -198,2 +198,38 @@ /** | ||
/** | ||
* Takes a `Parser` and tries to match it without consuming any input. | ||
* | ||
* @example | ||
* import { run } from 'parser-ts/es6/code-frame' | ||
* import * as P from 'parser-ts/es6/Parser' | ||
* import * as S from 'parser-ts/es6/string' | ||
* | ||
* const parser = S.fold([ | ||
* S.string('hello '), | ||
* P.lookAhead(S.string('world')), | ||
* S.string('wor') | ||
* ]) | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: 'hello worldwor' } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
export declare const lookAhead: <I, A>(p: Parser<I, A>) => Parser<I, A>; | ||
/** | ||
* Takes a `Predicate` and continues parsing until the given `Predicate` is satisfied. | ||
* | ||
* @example | ||
* import * as C from 'parser-ts/es6/char' | ||
* import { run } from 'parser-ts/es6/code-frame' | ||
* import * as P from 'parser-ts/es6/Parser' | ||
* | ||
* const parser = P.takeUntil((c: C.Char) => c === 'w') | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: [ 'h', 'e', 'l', 'l', 'o', ' ' ] } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
export declare const takeUntil: <I>(predicate: Predicate<I>) => Parser<I, I[]>; | ||
/** | ||
* @since 0.6.0 | ||
@@ -200,0 +236,0 @@ */ |
@@ -14,2 +14,3 @@ var __assign = (this && this.__assign) || function () { | ||
import * as E from 'fp-ts/es6/Either'; | ||
import { not } from 'fp-ts/es6/function'; | ||
import { cons } from 'fp-ts/es6/NonEmptyArray'; | ||
@@ -258,2 +259,40 @@ import * as O from 'fp-ts/es6/Option'; | ||
/** | ||
* Takes a `Parser` and tries to match it without consuming any input. | ||
* | ||
* @example | ||
* import { run } from 'parser-ts/es6/code-frame' | ||
* import * as P from 'parser-ts/es6/Parser' | ||
* import * as S from 'parser-ts/es6/string' | ||
* | ||
* const parser = S.fold([ | ||
* S.string('hello '), | ||
* P.lookAhead(S.string('world')), | ||
* S.string('wor') | ||
* ]) | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: 'hello worldwor' } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
export var lookAhead = function (p) { return function (i) { | ||
return E.either.chain(p(i), function (next) { return success(next.value, i, i); }); | ||
}; }; | ||
/** | ||
* Takes a `Predicate` and continues parsing until the given `Predicate` is satisfied. | ||
* | ||
* @example | ||
* import * as C from 'parser-ts/es6/char' | ||
* import { run } from 'parser-ts/es6/code-frame' | ||
* import * as P from 'parser-ts/es6/Parser' | ||
* | ||
* const parser = P.takeUntil((c: C.Char) => c === 'w') | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: [ 'h', 'e', 'l', 'l', 'o', ' ' ] } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
export var takeUntil = function (predicate) { return many(sat(not(predicate))); }; | ||
/** | ||
* @since 0.6.0 | ||
@@ -260,0 +299,0 @@ */ |
@@ -198,2 +198,38 @@ /** | ||
/** | ||
* Takes a `Parser` and tries to match it without consuming any input. | ||
* | ||
* @example | ||
* import { run } from 'parser-ts/lib/code-frame' | ||
* import * as P from 'parser-ts/lib/Parser' | ||
* import * as S from 'parser-ts/lib/string' | ||
* | ||
* const parser = S.fold([ | ||
* S.string('hello '), | ||
* P.lookAhead(S.string('world')), | ||
* S.string('wor') | ||
* ]) | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: 'hello worldwor' } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
export declare const lookAhead: <I, A>(p: Parser<I, A>) => Parser<I, A>; | ||
/** | ||
* Takes a `Predicate` and continues parsing until the given `Predicate` is satisfied. | ||
* | ||
* @example | ||
* import * as C from 'parser-ts/lib/char' | ||
* import { run } from 'parser-ts/lib/code-frame' | ||
* import * as P from 'parser-ts/lib/Parser' | ||
* | ||
* const parser = P.takeUntil((c: C.Char) => c === 'w') | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: [ 'h', 'e', 'l', 'l', 'o', ' ' ] } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
export declare const takeUntil: <I>(predicate: Predicate<I>) => Parser<I, I[]>; | ||
/** | ||
* @since 0.6.0 | ||
@@ -200,0 +236,0 @@ */ |
@@ -16,2 +16,3 @@ "use strict"; | ||
var E = require("fp-ts/lib/Either"); | ||
var function_1 = require("fp-ts/lib/function"); | ||
var NonEmptyArray_1 = require("fp-ts/lib/NonEmptyArray"); | ||
@@ -280,2 +281,40 @@ var O = require("fp-ts/lib/Option"); | ||
/** | ||
* Takes a `Parser` and tries to match it without consuming any input. | ||
* | ||
* @example | ||
* import { run } from 'parser-ts/lib/code-frame' | ||
* import * as P from 'parser-ts/lib/Parser' | ||
* import * as S from 'parser-ts/lib/string' | ||
* | ||
* const parser = S.fold([ | ||
* S.string('hello '), | ||
* P.lookAhead(S.string('world')), | ||
* S.string('wor') | ||
* ]) | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: 'hello worldwor' } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
exports.lookAhead = function (p) { return function (i) { | ||
return E.either.chain(p(i), function (next) { return ParseResult_1.success(next.value, i, i); }); | ||
}; }; | ||
/** | ||
* Takes a `Predicate` and continues parsing until the given `Predicate` is satisfied. | ||
* | ||
* @example | ||
* import * as C from 'parser-ts/lib/char' | ||
* import { run } from 'parser-ts/lib/code-frame' | ||
* import * as P from 'parser-ts/lib/Parser' | ||
* | ||
* const parser = P.takeUntil((c: C.Char) => c === 'w') | ||
* | ||
* run(parser, 'hello world') | ||
* // { _tag: 'Right', right: [ 'h', 'e', 'l', 'l', 'o', ' ' ] } | ||
* | ||
* @since 0.6.6 | ||
*/ | ||
exports.takeUntil = function (predicate) { return many(sat(function_1.not(predicate))); }; | ||
/** | ||
* @since 0.6.0 | ||
@@ -282,0 +321,0 @@ */ |
{ | ||
"name": "parser-ts", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"description": "String parser combinators for TypeScript", | ||
@@ -16,4 +16,4 @@ "files": [ | ||
"mocha": "mocha -r ts-node/register test/*.ts", | ||
"prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test}/**/*.ts\"", | ||
"fix-prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test}/**/*.ts\"", | ||
"prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test,examples}/**/*.ts\"", | ||
"fix-prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test,examples}/**/*.ts\"", | ||
"test": "npm run lint && npm run prettier && npm run jest && npm run docs", | ||
@@ -44,5 +44,6 @@ "clean": "rm -rf ./lib ./es6", | ||
"@types/node": "7.0.4", | ||
"docs-ts": "^0.3.4", | ||
"docs-ts": "^0.5.1", | ||
"dtslint": "^0.4.2", | ||
"fp-ts": "^2.0.0", | ||
"fp-ts-contrib": "^0.1.17", | ||
"import-path-rewrite": "github:gcanti/import-path-rewrite", | ||
@@ -49,0 +50,0 @@ "jest": "^24.8.0", |
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
82676
2759
15