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

balanced-match

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balanced-match - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

21

index.js

@@ -1,4 +0,7 @@

'use strict'
module.exports = balanced
function balanced (a, b, str) {
/**
* @param {string | RegExp} a
* @param {string | RegExp} b
* @param {string} str
*/
export default function balanced (a, b, str) {
if (a instanceof RegExp) a = maybeMatch(a, str)

@@ -20,2 +23,6 @@ if (b instanceof RegExp) b = maybeMatch(b, str)

/**
* @param {RegExp} reg
* @param {string} str
*/
function maybeMatch (reg, str) {

@@ -26,4 +33,8 @@ const m = str.match(reg)

balanced.range = range
function range (a, b, str) {
/**
* @param {string} a
* @param {string} b
* @param {string} str
*/
export function range (a, b, str) {
let begs, beg, left, right, result

@@ -30,0 +41,0 @@ let ai = str.indexOf(a)

{
"name": "balanced-match",
"description": "Match balanced character pairs, like \"{\" and \"}\"",
"version": "2.0.0",
"version": "3.0.0",
"repository": {

@@ -11,4 +11,5 @@ "type": "git",

"main": "index.js",
"type": "module",
"scripts": {
"test": "prettier-standard && standard && tape test/test.js",
"test": "standard --fix && node--test test/test.js",
"bench": "matcha test/bench.js",

@@ -19,6 +20,5 @@ "release": "np"

"@c4312/matcha": "^1.3.1",
"np": "^7.4.0",
"prettier-standard": "^16.4.1",
"standard": "^16.0.3",
"tape": "^4.6.0"
"np": "^8.0.4",
"standard": "^17.1.0",
"test": "^3.3.0"
},

@@ -53,3 +53,6 @@ "keywords": [

]
},
"engines": {
"node": ">= 16"
}
}

@@ -5,7 +5,5 @@ # balanced-match

[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
[![CI](https://github.com/juliangruber/balanced-match/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/balanced-match/actions/workflows/ci.yml)
[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
## Example

@@ -16,3 +14,3 @@

```js
var balanced = require('balanced-match')
import balanced from 'balanced-match'

@@ -39,3 +37,3 @@ console.log(balanced('{', '}', 'pre{in{nested}}post'))

### var m = balanced(a, b, str)
### const m = balanced(a, b, str)

@@ -55,3 +53,3 @@ For the first non-nested matching pair of `a` and `b` in `str`, return an

### var r = balanced.range(a, b, str)
### const r = balanced.range(a, b, str)

@@ -58,0 +56,0 @@ For the first non-nested matching pair of `a` and `b` in `str`, return an

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