This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

bracket-balance

1.0.2 • Public • Published

bracket-balance - get the difference between opening and closing brackets in a string

Installation

npm install bracket-balance --save

Example

const bracketBalance = require('bracket-balance');
let exampleString = '{hello{{ ]}';

bracketBalance(exampleString, '{}');
//returns 2 because there are 2 more opening than closing brackets

Definition

Arguments

  1. String to search through
  2. String containing a pair of brackets ('{}', '()' or '[]')

Returns

Number representing the difference between opening and closing brackets

  • bigger than 0 means there are more opening than closing brackets
  • exactly 0 means that there is an closing one for each opening bracket
  • smaller than 0 means there are more closing than opening brackets

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i bracket-balance

      Weekly Downloads

      1

      Version

      1.0.2

      License

      MIT

      Last publish

      Collaborators

      • robojones