🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

fretted-strings

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fretted-strings

Mark on your strings and get it's position

Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
1.6K
27.53%
Maintainers
1
Weekly downloads
 
Created
Source

fretted-strings

npm version GitHub license

Marks on your strings and get it's position.

npm i fretted-strings

Basic usage

const assert = require('assert');
const { mark } = require('fretted-strings');

const frets = {};
const content = mark(
  `
      hogehoge
  %%% ^      ^   %%%
  %%% p1     p2  %%%
      fooo`,
  frets,
);

// Function `mark` returns a string which is removed lines enclosed by '%%%' tags from the parameter.
assert.equal(
  content,
  `
      hogehoge
      fooo`,
);

// And this function assigns specified location whose name is represented
// as identifier under the `^` character to 2nd parameter.
assert.equal(frets.p1.pos, 7);
assert.equal(frets.p1.line, 1);
assert.equal(frets.p1.character, 6);

assert.equal(frets.p2.pos, 14);
assert.equal(frets.p2.line, 1);
assert.equal(frets.p2.character, 13);

Use custom tag

const { mark } = require('fretted-strings');

setOptions({
  tagStart: '<!--%%',
  tagEnd: '%%-->',
});

const frets = {};

mark(
  `
    <html>
      <div>hogehoge</div>
      <!--%%   ^    %%-->
      <!--%%   p    %%-->
    </html>
  `,
  frets,
);

Or

const { mark } = require('fretted-strings');

const marker = new FretsMarker({
  tagStart: '<!--%%',
  tagEnd: '%%-->',
});

const frets = {};

marker.mark(
  `
    <html>
      <div>hogehoge</div>
      <!--%%   ^    %%-->
      <!--%%   p    %%-->
    </html>
  `,
  frets,
);

LICENSE

MIT

Keywords

string

FAQs

Package last updated on 04 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts