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

arcsecond

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arcsecond - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

35

index.js

@@ -7,3 +7,3 @@ "use strict";

exports.Parser = Parser;
exports.toValue = exports.toPromise = exports.takeLeft = exports.takeRight = exports.recursiveParser = exports.optionalWhitespace = exports.whitespace = exports.endOfInput = exports.skip = exports.possibly = exports.lookAhead = exports.anyCharExcept = exports.anythingExcept = exports.everyCharUntil = exports.everythingUntil = exports.between = exports.choice = exports.sepBy1 = exports.sepBy = exports.sequenceOf = exports.namedSequenceOf = exports.anyOfString = exports.letters = exports.letter = exports.digits = exports.digit = exports.regex = exports.str = exports.peek = exports.anyChar = exports.char = exports.errorMapTo = exports.mapTo = exports.many1 = exports.many = exports.coroutine = exports.either = exports.succeedWith = exports.fail = exports.decide = exports.parse = exports.tapParser = exports.composeParsers = exports.pipeParsers = exports.withData = exports.mapData = exports.setData = exports.getData = void 0;
exports.toValue = exports.toPromise = exports.takeLeft = exports.takeRight = exports.recursiveParser = exports.optionalWhitespace = exports.whitespace = exports.endOfInput = exports.skip = exports.possibly = exports.lookAhead = exports.anyCharExcept = exports.anythingExcept = exports.everyCharUntil = exports.everythingUntil = exports.between = exports.choice = exports.sepBy1 = exports.sepBy = exports.sequenceOf = exports.namedSequenceOf = exports.anyOfString = exports.letters = exports.letter = exports.digits = exports.digit = exports.regex = exports.str = exports.peek = exports.anyChar = exports.char = exports.errorMapTo = exports.mapTo = exports.many1 = exports.many = exports.exactly = exports.coroutine = exports.either = exports.succeedWith = exports.fail = exports.decide = exports.parse = exports.tapParser = exports.composeParsers = exports.pipeParsers = exports.withData = exports.mapData = exports.setData = exports.getData = void 0;
const reDigit = /[0-9]/;

@@ -14,2 +14,3 @@ const reDigits = /^[0-9]+/;

const reWhitespaces = /^\s+/;
const reErrorExpectation = /ParseError.+Expecting/;

@@ -422,2 +423,34 @@ const isTypedArray = x => x instanceof Uint8Array || x instanceof Uint8ClampedArray || x instanceof Int8Array || x instanceof Uint16Array || x instanceof Int16Array || x instanceof Uint32Array || x instanceof Int32Array || x instanceof Float32Array || x instanceof Float64Array;

const exactly = function exactly(n) {
if (typeof n !== 'number' || n <= 0) {
throw new TypeError(`exactly must be called with a number > 0, but got ${n}`);
}
return function exactly$factory(parser) {
return new Parser(function exactly$factory$state(state) {
if (state.isError) return state;
const results = [];
let nextState = state;
for (let i = 0; i < n; i++) {
const out = parser.p(nextState);
if (out.isError) {
return out;
} else {
nextState = out;
results.push(nextState.result);
}
}
return updateResult(nextState, results);
}).errorMap(({
index,
error
}) => `ParseError (position ${index}): Expecting ${n}${error.replace(reErrorExpectation, '')}`);
};
};
exports.exactly = exactly;
const many = function many(parser) {

@@ -424,0 +457,0 @@ return new Parser(function many$state(state) {

2

package.json
{
"name": "arcsecond",
"version": "3.0.0",
"version": "3.1.0",
"description": "",

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

@@ -54,2 +54,3 @@ # Arcsecond

- [sepBy1](#sepBy1)
- [exactly](#exactly)
- [many](#many)

@@ -1092,2 +1093,37 @@ - [many1](#many1)

#### exactly
`exactly :: (Integer) -> (Parser e s a) -> Parser e s [a]`
`exactly` takes a positive number and returns a function. That function takes a parser and returns a new parser which matches the given parser the specified number of times.
**Example**
```JavaScript
const newParser = exactly (4)(letter)
newParser.run('abcdef')
// -> {
// isError: false,
// result: [ "a", "b", "c", "d" ],
// index: 4,
// data: null
// }
newParser.run('abc')
// -> {
// isError: true,
// error: 'ParseError (position 0): Expecting 4 letter, but got end of input.',
// index: 0,
// data: null
// }
newParser.run('12345')
// -> {
// isError: true,
// error: 'ParseError (position 0): Expecting 4 letter, got '1'',
// index: 0,
// data: null
// }
```
#### many

@@ -1094,0 +1130,0 @@

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