Socket
Socket
Sign inDemoInstall

moo

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moo - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

40

moo.js

@@ -49,3 +49,2 @@ (function(root, factory) {

if (obj.multiline) throw new Error('RegExp /m flag is implied')
if (obj.unicode) throw new Error('RegExp /u flag is not allowed')
return obj.source

@@ -158,2 +157,3 @@

var fastAllowed = true
var unicodeFlag = null
var groups = []

@@ -189,3 +189,3 @@ var parts = []

var match = options.match
var match = options.match.slice()
if (fastAllowed) {

@@ -216,2 +216,16 @@ while (match.length && typeof match[0] === 'string' && match[0].length === 1) {

// Check unicode flag is used everywhere or nowhere
for (var j = 0; j < match.length; j++) {
var obj = match[j]
if (!isRegExp(obj)) {
continue
}
if (unicodeFlag === null) {
unicodeFlag = obj.unicode
} else if (unicodeFlag !== obj.unicode && options.fallback === false) {
throw new Error('If one rule is /u then all must be')
}
}
// convert to RegExp

@@ -248,4 +262,5 @@ var pat = reUnion(match.map(regexpOrLiteral))

var suffix = hasSticky || fallbackRule ? '' : '|'
if (unicodeFlag === true) flags += "u"
var combined = new RegExp(reUnion(parts) + suffix, flags)
return {regexp: combined, groups: groups, fast: fast, error: errorRule || defaultErrorRule}

@@ -553,7 +568,16 @@ }

Lexer.prototype.formatError = function(token, message) {
var value = token.text
var index = token.offset
var eol = token.lineBreaks ? value.indexOf('\n') : value.length
var start = Math.max(0, index - token.col + 1)
var firstLine = this.buffer.substring(start, index + eol)
if (token == null) {
// An undefined token indicates EOF
var text = this.buffer.slice(this.index)
var token = {
text: text,
offset: this.index,
lineBreaks: text.indexOf('\n') === -1 ? 0 : 1,
line: this.line,
col: this.col,
}
}
var start = Math.max(0, token.offset - token.col + 1)
var eol = token.lineBreaks ? token.text.indexOf('\n') : token.text.length
var firstLine = this.buffer.substring(start, token.offset + eol)
message += " at line " + token.line + " col " + token.col + ":\n\n"

@@ -560,0 +584,0 @@ message += " " + firstLine + "\n"

6

package.json
{
"name": "moo",
"version": "0.5.0",
"version": "0.5.1",
"description": "Optimised tokenizer/lexer generator! πŸ„ Much performance. Moo!",

@@ -22,4 +22,4 @@ "main": "moo.js",

"benchr": "^3.2.0",
"chevrotain": "^0.27.1",
"jest": "^23.6.0",
"chevrotain": "4.2.0",
"jest": "24.7.1",
"lex": "^1.7.9",

@@ -26,0 +26,0 @@ "lexing": "^0.8.0",

@@ -17,3 +17,3 @@ ![](cow.png)

* has no dependencies
* <3KB gzipped
* 4KB minified + gzipped
* Moo!

@@ -20,0 +20,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