New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.6.2 to 0.6.3

7

CHANGELOG.md

@@ -16,2 +16,9 @@ # Changelog

# 0.6.3
- **Bug Fix**
- don't set `target: es6` in `tsconfig.build-es6.json` (@gcanti)
- **Internal**
- upgrade to latest `docs-ts` (@gcanti)
# 0.6.2

@@ -18,0 +25,0 @@

38

es6/char.js

@@ -8,3 +8,3 @@ /**

import * as P from './Parser';
const maybe = P.maybe(monoidString);
var maybe = P.maybe(monoidString);
/**

@@ -26,3 +26,3 @@ * Takes a `Parser<Char, string>` and matches it zero or more times, returning

export function many1(parser) {
return pipe(P.many1(parser), P.map(nea => nea.join('')));
return pipe(P.many1(parser), P.map(function (nea) { return nea.join(''); }));
}

@@ -36,3 +36,3 @@ /**

export function char(c) {
return P.expected(P.sat(s => s === c), `"${c}"`);
return P.expected(P.sat(function (s) { return s === c; }), "\"" + c + "\"");
}

@@ -46,3 +46,3 @@ /**

export function notChar(c) {
return P.expected(P.sat(c1 => c1 !== c), `anything but "${c}"`);
return P.expected(P.sat(function (c1) { return c1 !== c; }), "anything but \"" + c + "\"");
}

@@ -58,3 +58,3 @@ function isOneOf(s, c) {

export function oneOf(s) {
return P.expected(P.sat(c => isOneOf(s, c)), `One of "${s}"`);
return P.expected(P.sat(function (c) { return isOneOf(s, c); }), "One of \"" + s + "\"");
}

@@ -69,4 +69,4 @@ function isDigit(c) {

*/
export const digit = P.expected(P.sat(isDigit), 'a digit');
const spaceRe = /^\s$/;
export var digit = P.expected(P.sat(isDigit), 'a digit');
var spaceRe = /^\s$/;
function isSpace(c) {

@@ -80,3 +80,3 @@ return spaceRe.test(c);

*/
export const space = P.expected(P.sat(isSpace), 'a whitespace');
export var space = P.expected(P.sat(isSpace), 'a whitespace');
function isUnderscore(c) {

@@ -96,3 +96,3 @@ return c === '_';

*/
export const alphanum = P.expected(P.sat(isAlphanum), 'a word character');
export var alphanum = P.expected(P.sat(isAlphanum), 'a word character');
/**

@@ -103,3 +103,3 @@ * Matches a single ASCII letter.

*/
export const letter = P.expected(P.sat(isLetter), 'a letter');
export var letter = P.expected(P.sat(isLetter), 'a letter');
function isUpper(c) {

@@ -113,3 +113,3 @@ return isLetter(c) && c === c.toUpperCase();

*/
export const upper = P.expected(P.sat(isUpper), 'an upper case letter');
export var upper = P.expected(P.sat(isUpper), 'an upper case letter');
function isLower(c) {

@@ -123,3 +123,3 @@ return isLetter(c) && c === c.toLowerCase();

*/
export const lower = P.expected(P.sat(isLower), 'a lower case letter');
export var lower = P.expected(P.sat(isLower), 'a lower case letter');
/**

@@ -131,3 +131,3 @@ * Matches a single character which isn't a character from the provided string.

export function notOneOf(s) {
return P.expected(P.sat(c => !isOneOf(s, c)), `Not one of ${JSON.stringify(s)}`);
return P.expected(P.sat(function (c) { return !isOneOf(s, c); }), "Not one of " + JSON.stringify(s));
}

@@ -139,3 +139,3 @@ /**

*/
export const notDigit = P.expected(P.sat(not(isDigit)), 'a non-digit');
export var notDigit = P.expected(P.sat(not(isDigit)), 'a non-digit');
/**

@@ -146,3 +146,3 @@ * Matches a single character which isn't whitespace.

*/
export const notSpace = P.expected(P.sat(not(isSpace)), 'a non-whitespace character');
export var notSpace = P.expected(P.sat(not(isSpace)), 'a non-whitespace character');
/**

@@ -153,3 +153,3 @@ * Matches a single character which isn't a letter, digit or underscore.

*/
export const notAlphanum = P.expected(P.sat(not(isAlphanum)), 'a non-word character');
export var notAlphanum = P.expected(P.sat(not(isAlphanum)), 'a non-word character');
/**

@@ -160,3 +160,3 @@ * Matches a single character which isn't an ASCII letter.

*/
export const notLetter = P.expected(P.sat(not(isLetter)), 'a non-letter character');
export var notLetter = P.expected(P.sat(not(isLetter)), 'a non-letter character');
/**

@@ -167,3 +167,3 @@ * Matches a single character which isn't an upper case ASCII letter.

*/
export const notUpper = P.expected(P.sat(not(isUpper)), 'anything but an upper case letter');
export var notUpper = P.expected(P.sat(not(isUpper)), 'anything but an upper case letter');
/**

@@ -174,2 +174,2 @@ * Matches a single character which isn't a lower case ASCII letter.

*/
export const notLower = P.expected(P.sat(not(isLower)), 'anything but a lower case letter');
export var notLower = P.expected(P.sat(not(isLower)), 'anything but a lower case letter');

@@ -7,10 +7,10 @@ /**

import { stream } from './Stream';
const { codeFrameColumns } = require('@babel/code-frame');
var codeFrameColumns = require('@babel/code-frame').codeFrameColumns;
function getLocation(source, cursor) {
let line = 1;
let column = 1;
let i = 0;
var line = 1;
var column = 1;
var i = 0;
while (i < cursor) {
i++;
const c = source.charAt(i);
var c = source.charAt(i);
if (c === '\n') {

@@ -26,4 +26,4 @@ line++;

start: {
line,
column
line: line,
column: column
}

@@ -38,5 +38,7 @@ };

export function run(p, source) {
return pipe(p(stream(source.split(''))), bimap(err => codeFrameColumns(source, getLocation(source, err.input.cursor), {
message: 'Expected: ' + err.expected.join(', ')
}), succ => succ.value));
return pipe(p(stream(source.split(''))), bimap(function (err) {
return codeFrameColumns(source, getLocation(source, err.input.cursor), {
message: 'Expected: ' + err.expected.join(', ')
});
}, function (succ) { return succ.value; }));
}

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

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { empty } from 'fp-ts/es6/Array';

@@ -11,3 +22,3 @@ import * as E from 'fp-ts/es6/Either';

*/
export const URI = 'Parser';
export var URI = 'Parser';
/**

@@ -22,3 +33,3 @@ * The `succeed` parser constructor creates a parser which will simply

export function succeed(a) {
return i => success(a, i, i);
return function (i) { return success(a, i, i); };
}

@@ -31,3 +42,3 @@ /**

export function fail() {
return i => error(i);
return function (i) { return error(i); };
}

@@ -41,3 +52,3 @@ /**

export function failAt(i) {
return () => error(i);
return function () { return error(i); };
}

@@ -52,3 +63,5 @@ /**

export function expected(p, message) {
return i => pipe(p(i), E.mapLeft(err => withExpected(err, [message])));
return function (i) {
return pipe(p(i), E.mapLeft(function (err) { return withExpected(err, [message]); }));
};
}

@@ -62,3 +75,8 @@ /**

export function item() {
return i => pipe(getAndNext(i), O.fold(() => error(i), ({ value, next }) => success(value, next, i)));
return function (i) {
return pipe(getAndNext(i), O.fold(function () { return error(i); }, function (_a) {
var value = _a.value, next = _a.next;
return success(value, next, i);
}));
};
}

@@ -73,3 +91,3 @@ /**

export function cut(p) {
return i => pipe(p(i), E.mapLeft(escalate));
return function (i) { return pipe(p(i), E.mapLeft(escalate)); };
}

@@ -98,3 +116,3 @@ /**

export function seq(fa, f) {
return i => E.either.chain(fa(i), s => E.either.chain(f(s.value)(s.next), next => success(next.value, next.next, i)));
return function (i) { return E.either.chain(fa(i), function (s) { return E.either.chain(f(s.value)(s.next), function (next) { return success(next.value, next.next, i); }); }); };
}

@@ -114,4 +132,4 @@ /**

export function either(p, f) {
return i => {
const e = p(i);
return function (i) {
var e = p(i);
if (E.isRight(e)) {

@@ -123,3 +141,3 @@ return e;

}
return pipe(f()(i), E.mapLeft(err => extend(e.left, err)));
return pipe(f()(i), E.mapLeft(function (err) { return extend(e.left, err); }));
};

@@ -137,3 +155,5 @@ }

export function withStart(p) {
return i => pipe(p(i), E.map(s => (Object.assign({}, s, { value: [s.value, i] }))));
return function (i) {
return pipe(p(i), E.map(function (s) { return (__assign({}, s, { value: [s.value, i] })); }));
};
}

@@ -149,3 +169,6 @@ /**

export function sat(predicate) {
return pipe(withStart(item()), chain(([a, start]) => (predicate(a) ? parser.of(a) : failAt(start))));
return pipe(withStart(item()), chain(function (_a) {
var a = _a[0], start = _a[1];
return (predicate(a) ? parser.of(a) : failAt(start));
}));
}

@@ -160,3 +183,3 @@ /**

export function maybe(M) {
return alt(() => parser.of(M.empty));
return alt(function () { return parser.of(M.empty); });
}

@@ -169,3 +192,3 @@ /**

export function eof() {
return expected(i => (atEnd(i) ? success(undefined, i, i) : error(i)), 'end of file');
return expected(function (i) { return (atEnd(i) ? success(undefined, i, i) : error(i)); }, 'end of file');
}

@@ -184,3 +207,3 @@ /**

export function many(p) {
return pipe(many1(p), alt(() => parser.of(empty)));
return pipe(many1(p), alt(function () { return parser.of(empty); }));
}

@@ -195,3 +218,3 @@ /**

export function many1(p) {
return parser.chain(p, head => parser.map(many(p), tail => cons(head, tail)));
return parser.chain(p, function (head) { return parser.map(many(p), function (tail) { return cons(head, tail); }); });
}

@@ -206,4 +229,4 @@ /**

export function sepBy(sep, p) {
const nil = parser.of(empty);
return pipe(sepBy1(sep, p), alt(() => nil));
var nil = parser.of(empty);
return pipe(sepBy1(sep, p), alt(function () { return nil; }));
}

@@ -218,4 +241,4 @@ /**

export function sepBy1(sep, p) {
const bs = many(pipe(sep, apSecond(p)));
return parser.chain(p, head => parser.map(bs, tail => cons(head, tail)));
var bs = many(pipe(sep, apSecond(p)));
return parser.chain(p, function (head) { return parser.map(bs, function (tail) { return cons(head, tail); }); });
}

@@ -228,4 +251,4 @@ /**

export function sepByCut(sep, p) {
const bs = many(cutWith(sep, p));
return parser.chain(p, head => parser.map(bs, tail => cons(head, tail)));
var bs = many(cutWith(sep, p));
return parser.chain(p, function (head) { return parser.map(bs, function (tail) { return cons(head, tail); }); });
}

@@ -237,3 +260,5 @@ /**

return {
concat: (x, y) => parser.ap(parser.map(x, (x) => (y) => M.concat(x, y)), y),
concat: function (x, y) {
return parser.ap(parser.map(x, function (x) { return function (y) { return M.concat(x, y); }; }), y);
},
empty: succeed(M.empty)

@@ -245,7 +270,7 @@ };

*/
export const parser = {
URI,
map: (fa, f) => i => E.either.map(fa(i), s => (Object.assign({}, s, { value: f(s.value) }))),
export var parser = {
URI: URI,
map: function (fa, f) { return function (i) { return E.either.map(fa(i), function (s) { return (__assign({}, s, { value: f(s.value) })); }); }; },
of: succeed,
ap: (fab, fa) => parser.chain(fab, f => parser.map(fa, f)),
ap: function (fab, fa) { return parser.chain(fab, function (f) { return parser.map(fa, f); }); },
chain: seq,

@@ -255,3 +280,3 @@ alt: either,

};
const { alt, ap, apFirst, apSecond, chain, chainFirst, flatten, map } = pipeable(parser);
var _a = pipeable(parser), alt = _a.alt, ap = _a.ap, apFirst = _a.apFirst, apSecond = _a.apSecond, chain = _a.chain, chainFirst = _a.chainFirst, flatten = _a.flatten, map = _a.map;
export {

@@ -258,0 +283,0 @@ /**

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

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**

@@ -10,3 +21,3 @@ * @since 0.6.0

export function withExpected(err, expected) {
return Object.assign({}, err, { expected });
return __assign({}, err, { expected: expected });
}

@@ -17,3 +28,3 @@ /**

export function escalate(err) {
return Object.assign({}, err, { fatal: true });
return __assign({}, err, { fatal: true });
}

@@ -31,3 +42,3 @@ /**

else {
return Object.assign({}, err1, { expected: err1.expected.concat(err2.expected) });
return __assign({}, err1, { expected: err1.expected.concat(err2.expected) });
}

@@ -40,5 +51,5 @@ }

return right({
value,
next,
start
value: value,
next: next,
start: start
});

@@ -49,8 +60,10 @@ }

*/
export function error(input, expected = empty, fatal = false) {
export function error(input, expected, fatal) {
if (expected === void 0) { expected = empty; }
if (fatal === void 0) { fatal = false; }
return left({
input,
expected,
fatal
input: input,
expected: expected,
fatal: fatal
});
}

@@ -11,4 +11,5 @@ /**

*/
export function stream(buffer, cursor = 0) {
return { buffer, cursor };
export function stream(buffer, cursor) {
if (cursor === void 0) { cursor = 0; }
return { buffer: buffer, cursor: cursor };
}

@@ -31,3 +32,3 @@ /**

export function getAndNext(s) {
return pipe(get(s), map(a => ({ value: a, next: { buffer: s.buffer, cursor: s.cursor + 1 } })));
return pipe(get(s), map(function (a) { return ({ value: a, next: { buffer: s.buffer, cursor: s.cursor + 1 } }); }));
}

@@ -38,4 +39,4 @@ /**

export function getEq(E) {
const EA = getArrayEq(E);
return fromEquals((x, y) => x.cursor === y.cursor && EA.equals(x.buffer, y.buffer));
var EA = getArrayEq(E);
return fromEquals(function (x, y) { return x.cursor === y.cursor && EA.equals(x.buffer, y.buffer); });
}

@@ -9,3 +9,3 @@ import * as M from 'fp-ts/es6/Monoid';

*/
export const maybe = P.maybe(M.monoidString);
export var maybe = P.maybe(M.monoidString);
/**

@@ -27,3 +27,3 @@ * Matches the given parser zero or more times, returning a string of the

export function many1(parser) {
return pipe(P.many1(parser), P.map(nea => nea.join('')));
return pipe(P.many1(parser), P.map(function (nea) { return nea.join(''); }));
}

@@ -40,3 +40,5 @@ function charAt(index, s) {

function _string(s2) {
return pipe(charAt(0, s2), O.fold(() => P.succeed(''), c => pipe(C.char(c), P.chain(() => _string(s2.slice(1))), P.chain(() => P.succeed(s)))));
return pipe(charAt(0, s2), O.fold(function () { return P.succeed(''); }, function (c) {
return pipe(C.char(c), P.chain(function () { return _string(s2.slice(1)); }), P.chain(function () { return P.succeed(s); }));
}));
}

@@ -46,3 +48,7 @@ return P.expected(_string(s), JSON.stringify(s));

export function oneOf(F) {
return ss => F.reduce(ss, P.fail(), (p, s) => pipe(p, P.alt(() => string(s))));
return function (ss) {
return F.reduce(ss, P.fail(), function (p, s) {
return pipe(p, P.alt(function () { return string(s); }));
});
};
}

@@ -54,3 +60,3 @@ /**

*/
export const spaces = C.many(C.space);
export var spaces = C.many(C.space);
/**

@@ -61,3 +67,3 @@ * Matches one or more whitespace characters.

*/
export const spaces1 = C.many1(C.space);
export var spaces1 = C.many1(C.space);
/**

@@ -68,3 +74,3 @@ * Matches zero or more non-whitespace characters.

*/
export const notSpaces = C.many(C.notSpace);
export var notSpaces = C.many(C.notSpace);
/**

@@ -75,9 +81,9 @@ * Matches one or more non-whitespace characters.

*/
export const notSpaces1 = C.many1(C.notSpace);
export var notSpaces1 = C.many1(C.notSpace);
/**
* @since 0.6.0
*/
export const fold = M.fold(P.getMonoid(M.monoidString));
export var fold = M.fold(P.getMonoid(M.monoidString));
function fromString(s) {
const n = +s;
var n = +s;
return isNaN(n) || s === '' ? O.none : O.some(n);

@@ -88,7 +94,9 @@ }

*/
export const int = P.expected(pipe(fold([maybe(C.char('-')), C.many1(C.digit)]), P.map(s => +s)), 'an integer');
export var int = P.expected(pipe(fold([maybe(C.char('-')), C.many1(C.digit)]), P.map(function (s) { return +s; })), 'an integer');
/**
* @since 0.6.0
*/
export const float = P.expected(pipe(fold([maybe(C.char('-')), C.many(C.digit), maybe(fold([C.char('.'), C.many1(C.digit)]))]), P.chain(s => pipe(fromString(s), O.fold(() => P.fail(), P.succeed)))), 'a float');
export var float = P.expected(pipe(fold([maybe(C.char('-')), C.many(C.digit), maybe(fold([C.char('.'), C.many1(C.digit)]))]), P.chain(function (s) {
return pipe(fromString(s), O.fold(function () { return P.fail(); }, P.succeed));
})), 'a float');
/**

@@ -101,2 +109,4 @@ * Parses a double quoted string, with support for escaping double quotes

*/
export const doubleQuotedString = pipe(C.char('"'), P.chain(() => many(P.either(string('\\"'), () => C.notChar('"')))), P.chain(s => pipe(C.char('"'), P.chain(() => P.succeed(s)))));
export var doubleQuotedString = pipe(C.char('"'), P.chain(function () { return many(P.either(string('\\"'), function () { return C.notChar('"'); })); }), P.chain(function (s) {
return pipe(C.char('"'), P.chain(function () { return P.succeed(s); }));
}));
{
"name": "parser-ts",
"version": "0.6.2",
"version": "0.6.3",
"description": "String parser combinators for TypeScript",

@@ -43,3 +43,3 @@ "files": [

"@types/node": "7.0.4",
"docs-ts": "^0.3.0",
"docs-ts": "^0.3.4",
"dtslint": "^0.4.2",

@@ -46,0 +46,0 @@ "fp-ts": "^2.0.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