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

parser-ts

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parser-ts - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

5

CHANGELOG.md

@@ -15,4 +15,9 @@ # Changelog

# 0.0.2
- **Bug Fix**
- fix `sepBy1`, https://github.com/gcanti/parser-ts/pull/1 (@sledorze)
# 0.0.1
Initial release

16

lib-jsnext/index.js

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

import { identity } from 'fp-ts/lib/function';
import { left, right } from 'fp-ts/lib/Either';

@@ -203,4 +204,15 @@ import { NonEmptyArray } from 'fp-ts/lib/NonEmptyArray';

export function sepBy(sep, parser) {
return alt(sepBy1(sep, parser).map(function (a) { return a.toArray(); }), of([]));
return alt(sepBy1(sep, parser).map(function (a) { return a.toArray(); }), alt(parser.map(function (a) { return [a]; }), of([])));
}
// to remove when lending in fp-ts
function applySecond(apply) {
return function (fa, fb) { return apply.ap(apply.map(function () { return identity; }, fa), fb); };
}
/** Matches both parsers and return the value of the second
*/
function second(pa, pb) {
return new Parser(function (s) {
return applySecond({ URI: URI, map: map, ap: ap })(pa, pb).run(s);
});
}
/** Matches the provided parser `p` one or more times, but requires the

@@ -211,3 +223,3 @@ * parser `sep` to match once in between each match of `p`. In other words,

export function sepBy1(sep, parser) {
return parser.chain(function (head) { return sepBy(sep, parser).chain(function (tail) { return of(new NonEmptyArray(head, tail)); }); });
return parser.chain(function (head) { return alt(many(second(sep, parser)), of([])).chain(function (tail) { return of(new NonEmptyArray(head, tail)); }); });
}

@@ -214,0 +226,0 @@ // tslint:disable-next-line no-unused-expression

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var function_1 = require("fp-ts/lib/function");
var Either_1 = require("fp-ts/lib/Either");

@@ -226,5 +227,16 @@ var NonEmptyArray_1 = require("fp-ts/lib/NonEmptyArray");

function sepBy(sep, parser) {
return alt(sepBy1(sep, parser).map(function (a) { return a.toArray(); }), of([]));
return alt(sepBy1(sep, parser).map(function (a) { return a.toArray(); }), alt(parser.map(function (a) { return [a]; }), of([])));
}
exports.sepBy = sepBy;
// to remove when lending in fp-ts
function applySecond(apply) {
return function (fa, fb) { return apply.ap(apply.map(function () { return function_1.identity; }, fa), fb); };
}
/** Matches both parsers and return the value of the second
*/
function second(pa, pb) {
return new Parser(function (s) {
return applySecond({ URI: exports.URI, map: map, ap: ap })(pa, pb).run(s);
});
}
/** Matches the provided parser `p` one or more times, but requires the

@@ -235,3 +247,3 @@ * parser `sep` to match once in between each match of `p`. In other words,

function sepBy1(sep, parser) {
return parser.chain(function (head) { return sepBy(sep, parser).chain(function (tail) { return of(new NonEmptyArray_1.NonEmptyArray(head, tail)); }); });
return parser.chain(function (head) { return alt(many(second(sep, parser)), of([])).chain(function (tail) { return of(new NonEmptyArray_1.NonEmptyArray(head, tail)); }); });
}

@@ -238,0 +250,0 @@ exports.sepBy1 = sepBy1;

2

package.json
{
"name": "parser-ts",
"version": "0.0.1",
"version": "0.0.2",
"description": "String parser combinators for TypeScript",

@@ -5,0 +5,0 @@ "files": [

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