Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@foliojs-fork/linebreak

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

@foliojs-fork/linebreak

An implementation of the Unicode Line Breaking Algorithm (UAX #14)

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @foliojs-fork/linebreak?

@foliojs-fork/linebreak is a JavaScript library for determining line break opportunities in text according to the Unicode Line Breaking Algorithm. It is useful for text layout engines, word processors, and other applications that need to handle text wrapping and line breaking in a way that conforms to Unicode standards.

What are @foliojs-fork/linebreak's main functionalities?

Basic Line Breaking

This feature allows you to break a string into lines according to the Unicode Line Breaking Algorithm. The code sample demonstrates how to use the library to break a sample text into lines and print each line.

const linebreak = require('@foliojs-fork/linebreak');
const str = 'This is a sample text that needs line breaking.';
const breaker = new linebreak(str);
let last = 0;
let bk;
while (!(bk = breaker.next()).done) {
  console.log(str.slice(last, bk.value.position));
  last = bk.value.position;
}

Custom Line Breaking Rules

This feature allows you to apply custom line breaking rules. The code sample demonstrates how to use the 'strict' line break rule to break a sample text into lines.

const linebreak = require('@foliojs-fork/linebreak');
const str = 'Custom rules for line breaking.';
const breaker = new linebreak(str, { lineBreak: 'strict' });
let last = 0;
let bk;
while (!(bk = breaker.next()).done) {
  console.log(str.slice(last, bk.value.position));
  last = bk.value.position;
}

Other packages similar to @foliojs-fork/linebreak

Keywords

FAQs

Package last updated on 07 Mar 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc