Giter VIP home page Giter VIP logo

safe-code-point's Introduction

safe-code-point

Package for determining whether the supplied code point is "safe". This module (well, code very much like it) was used to generate code points for Base65536, Base32768 and Base2048.

This package supports ES modules only.

Example

import SafeCodePoint from 'safe-code-point'

const safeCodePoint = await SafeCodePoint('12.0.0')
const numCodePoints = (1 << 16) + (1 << 20)

let numSafeCodePoints = 0
for (let codePoint = 0; codePoint < numCodePoints; codePoint++) {
  if (safeCodePoint(codePoint)) {
    numSafeCodePoints++
  }
}

console.log(numSafeCodePoints)

API

SafeCodePoint(version)

Returns a promise which resolves to a safeCodePoint function for the supplied version of Unicode.

Data is fetched from the Unicode website at run time. At the time of writing, supported version strings are a subset of those seen in that directory: '4.1.0' to '13.0.0'. (Earlier versions do not provide the data in the same consumable structure, and Unicode 14.0.0 is a work in progress.)

safeCodePoint(codePoint)

Returns a Boolean indicating whether the supplied code point is safe (is not a member of any unsafe Unicode General Categories, has a canonical combining class of 0 and survives all forms of normalization). codePoint should be an integer from 0 to 1114111 inclusive.

safeCodePoint.generalCategory(codepoint)

Returns the Unicode General Category of the supplied code point as a two-character string, e.g. "Lo" for "Letter, other".

safeCodePoint.wordBreak(codepoint)

Returns the Word_Break property value of the supplied code point, e.g. 'Numeric', 'ALetter' or (in most cases) undefined.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.