Socket
Book a DemoInstallSign in
Socket

flat-text-sequencer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

flat-text-sequencer

Turns text to a sequence of typed ranges

2.0.0
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

▶ flat text sequencer

Build Status

Looking to parse a custom text model, render markdown, or highlight code? Here's a module that chunks text into a sequence of typed ranges by pattern.

sequence('*if only* there was a way to make `this` a __sequence__', [
  { type: 'strong', pattern: /__.+?__/g },
  { type: 'em', pattern: /\*.+?\*/g },
  { type: 'code', pattern: /`.+?`/g }
])

From text to a sequence.

[
  { type: ['em'], data: '*if only*' },
  { type: [], data: ' there was a way to make ' },
  { type: ['code'], data: '`this`' },
  { type: [], data: ' a ' },
  { type: ['strong'], data: '__sequence__' }
]

Usage

Install it with npm:

npm install --save flat-text-sequencer

Load the package to your application:

const sequenceText = require('flat-text-sequecner')

And call it with your data:

const sequence = sequenceText(text, patterns)

API

Flat text sequencer exports a single function with the following signature:

(text: string, patterns: [{ type: string, pattern: RegExp }])
-> [{ type: [string], data: string }]

Author

Joonatan Vuorinen (@bearror)

FAQs

Package last updated on 29 Apr 2018

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.