1.1.0 • Published 3 years ago

textvarify v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

textvarify

npm version Downloads

The library to scrape and manage snippets from some text.

Install

    npm i textvarify

How to use

import {Snippet} from "textvarify/lib/snippet";
import {SnippetBorder} from "textvarify/lib/models/borders";

const text = 'Hello, {{user}}, i am a demo case.';

snippet = new Snippet(SnippetBorder.BRACE, 2); // init snippet as {{snippet}}
scraper = new Scraper(snippet); // init scraper

const values = scraper.getAllValues(text); // values = ['user'];
const borderValues = scraper.getAllValuesWithBorder(text); // borderValues = ['{{user}}'];

const maching = scraper.isMatch(text); // maching = true; there is at least one snippet in the text.