0.1.19 • Published 2 months ago

@trenskow/parse v0.1.19

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
2 months ago

@trenskow/parse

A small library for parsing a string into a tree.

Usage

Below is an example on how to use the library.

import parse from '@trenskow/parse';

parse('${', '}', { /* options */ }).do('This ${is ${my ${nested ${string}}}}');

The above example will return the following structure

[
    'This ', [
        'is ', [
            'my ', [
                'nested ',
                'string'
            ]
        ]
    ]
]

One caveat: opening and closing token cannot be the same.

Options

The following options are available.

NameDescriptionTypeDefault value
maxDepthDo not parse under a certain depth.NumberInfinity
ignoreInsideA string (or array of strings) indicating characters at which to ignore parsing in between (see example below).String or Array of String[]

ignoreInside

An example of ignore inside is this.

parse('[', ']', { ignoreInside: '"' }).do('This is ["my custom [string]"]')
// ➡ [ 'This is ', '"my custom [string]"' ]

License

See license in LICENSE.

0.1.19

2 months ago

0.1.18

3 months ago

0.1.16

4 months ago

0.1.17

4 months ago

0.1.10

10 months ago

0.1.11

9 months ago

0.1.12

8 months ago

0.1.13

8 months ago

0.1.14

7 months ago

0.1.15

7 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.9

10 months ago

0.1.6

10 months ago

0.1.5

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.0

2 years ago