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

compose-regexp

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compose-regexp - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

tests/integration.js

31

examples/regexp-parser.js

@@ -5,3 +5,3 @@ // We can't parse arbitrary RegExs with regular expressions, because nesting.

import {atomic, avoid, flags, either, lookBehind, namedCapture, sequence, suffix, lookAhead} from "../compose-regexp.js"
import {atomic, notAhead, flags, either, lookBehind, namedCapture, sequence, suffix, lookAhead} from "../compose-regexp.js"

@@ -137,3 +137,3 @@ const maybe = suffix("?")

['c', tag({ControlLetter})],
tag("NullEscape", ['0', avoid(DecimalDigit)]),
tag("NullEscape", ['0', notAhead(DecimalDigit)]),
HexEscapeSequence,

@@ -172,2 +172,11 @@ UnicodeEscapeSequence({U, N}),

const Termish = ({U, N}) => either(
tag({AssertionOpen}),
tag("GroupOpen", GroupOpen({U, N})),
SimpleTerm({U, N}),
"|",
CharacterClassOpen,
AssertionAndGroupClose
)
const SimpleTerm = ({U, N}) => U

@@ -183,14 +192,14 @@ ? either(

const Termish = ({U, N}) => either(
tag({AssertionOpen}),
tag("GroupOpen", GroupOpen({U, N})),
SimpleTerm({U, N}),
"|",
CharacterClassOpen,
AssertionAndGroupClose
)
const CharClassItem = ({U, N}) => either(
CharacterClassClose,
// TODO
)
console.log(Termish({U:true, N: true}))
const print = ({U,N})=> console.log({U,N, rx: Termish({U,N})})
print({U:true, N: true})
print({U:false, N: true})
print({U:false, N: false})
const a = foo
{
"name": "compose-regexp",
"version": "0.6.4",
"version": "0.6.5",
"description": "A set of functions to build and compose complex regular expressions",

@@ -43,3 +43,3 @@ "type": "module",

"devDependencies": {
"compose-regexp": "0.6.3",
"compose-regexp": "0.6.4",
"gosub": "1.0.0",

@@ -46,0 +46,0 @@ "ospec": "^4.1.1",

@@ -104,3 +104,3 @@ # compose-regexp.js

`compose-regexp` is reasonably small (~3.6 KiB after compression), and doesn't have dependencies. You can use it as a plain dependency, or, for client-side apps, in a server-side script that generates the RegExps that you ship to the browsers.
`compose-regexp` is reasonably small (~3.8 KiB after compression), and doesn't have dependencies. You can use it as a plain dependency, or, for client-side apps, in a server-side script that generates the RegExps that you ship to the browsers.

@@ -458,2 +458,4 @@ ## Usage

RegExps with captures have custom behavior when using `someString.split(regexp)`, which probably isn't what you want (the captures are inserted into the resulting arrays, with `undefined` for the capturing groups that didn't match). Avoid `atomic()` for that purpose.
----

@@ -460,0 +462,0 @@

@@ -19,3 +19,3 @@ import {atomic, capture, either, flags, lookAhead, maybe, sequence, suffix} from 'compose-regexp'

['\\', /[^]/],
['(?', /[^<]/],
['(?', /:|<?[=!]/],
/[\[\](]/

@@ -22,0 +22,0 @@ ))

@@ -20,3 +20,3 @@ // /!\ DO NOT EDIT MANUALLY /!\

var captureMatcher = /\\[^]|\(\?[^<]|[\[\](]/g
var captureMatcher = /\\[^]|\(\?(?::|<?[=!])|[\[\](]/g

@@ -23,0 +23,0 @@

@@ -737,2 +737,20 @@ import o from 'ospec'

o("look around assertions and non-capturing groups are ignored", function() {
o(sequence(/(?=)/, /()\1/))
.satisfies(r(/(?=)()\1/))
o(sequence(/(?!)/, /()\1/))
.satisfies(r(/(?!)()\1/))
o(sequence(/(?<=)/, /()\1/))
.satisfies(r(/(?<=)()\1/))
o(sequence(/(?<!)/, /()\1/))
.satisfies(r(/(?<!)()\1/))
o(sequence(/(?:)/, /()\1/))
.satisfies(r(/(?:)()\1/))
})
o("refs in final position are handled properly", function() {

@@ -1049,93 +1067,1 @@ o(sequence(/(a)\1/, "2"))

o.spec("integration", function() {
o("string", function() {
const tag = namedCapture
const str = atomic(sequence(
capture(either("'", '"')),
suffix("*?", either(
["\\", /[^]/],
/./
)),
ref(1)
))
let result
o(str).satisfies(r(/(?=(('|")(?:\\[^]|.)*?\2))\1/))
o(str.test('""')).equals(true)
result = capture(str).exec('""')
o(Array.isArray(result)).equals(true)
o(result).deepEquals(Object.assign([ '""', '""', '""', '"'], {index: 0, input:'""', groups: undefined}))
result = tag("string", str).exec('""')
o(result)
.deepEquals(Object.assign(
[ '""', '""', '""', '"'],
{
index: 0,
input:'""',
groups: nullProto({string: '""'})
}
))
const ws = atomic(suffix("+", either(
/\s/,
["/*", suffix("*?", /[^]/), '*/'],
["//", /.*?\n/]
)))
const e = flags.add("g",
either(
tag("whiteSpace", ws),
tag("url", atomic(["url(", suffix("?", ws), str, suffix("?", ws), ")"])),
tag("string", str),
tag("error", /[^]/)
)
)
e.lastIndex = 0
o(e.test('"sdfdjs"')).equals(true)
e.lastIndex = 0
o(e.test("'sdfdsf'")).equals(true)
e.lastIndex = 0
o(e.test('""')).equals(true)
e.lastIndex = 0
o(e.test("''")).equals(true)
let source = `"ababa" //foo
/* jojo
*/
url( "dada" )
url("dada")
"
`
e.lastIndex = 0
while((result = e.exec(source)) && !(result.groups.error )){
// console.log({result})
}
o(result.groups.error).equals('"')
o(result.index).equals(62)
source = `"ababa" //foo
/* jojo
*/
url( "dada" )
url("dada")
//"
`
e.lastIndex = 0
while((result = e.exec(source)) && !(result.groups.error)){}
o(result).equals(null)
})
})
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