npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lipitva

v0.0.4

Published

Lipitva - indic script utilities like transliteration, etc.

Downloads

13

Readme

lipitva

lipitva is a modular and efficient javascript port of python sanscript. In logic, It diverges from sanscript, only when the nature of JavaScript, TypeScript justifies such diverging. Interfaces are fine tuned for js eco-system.

Installation

npm

npm install --save lipitva

browser

<head>
  ...
</head>
<body>
  ...
  <!-- Bottom of body -->
  <script src="https://unpkg.com/lipitva/dist-umd/lipitva.min.js"></script>
</body>

Usage

Basic usage

For basic use cases, lipitva exports a singleton named lip. It is a pre-configured instance of Lip type. you can use it as follows

// ES6
import lip from 'lipitva';
// Browser
lip
// or
window.lip
const content = 'धर्मक्षेत्रे कुरुक्षेत्रे <b>समवेता</b> युयुत्सवः ।';
let teluguContent = lip.t({
    data: content,
    from: 'devanagari',
    to: 'telugu',
    suspendOn: new Set(['<']), // optional
    suspendOff: new Set(['>']), // optional
})
console.log(teluguContent); // logs "ధర్మక్షేత్రే కురుక్షేత్రే <b>సమవేతా</b> యుయుత్సవః ।"

We can also replace text-content of an HTMLElement with it's transliterated form using lip.te method. (te : transliterate-element). This method transliterates in-place in DOM. Thus it doesn't re-render DOM, or doesn't remove any callbacks. This operation's recursive nature also can be specified.

const elem = document.getElementById('my-element);
lip.te({
    elem,
    from: 'devanagari',
    to: 'gujarati',
    recursive: true, // optional
});

Modular usage (Recommended)

Instead of using default export, we can use lipitva in modular way. This way we can bundle only required functionality, and required scripts in our apps. This way we can also use enums, functional tools which are not exported in singleton. Following is an example, to demo how to include only devanagari, telugu, itrans scripts in our app.

// module A:
// A scripts registry, to manage scripts and script-maps efficiently
import { ScriptsRegistry } from 'lipitva/dist/registry';
// A helper interface to invoke various tools easily. default export `lip` is instance of this class.
import { Lip } from 'lipitva/dist/Lip';

import { Telugu } from 'lipitva/dist/scripts/brahmic/Telugu';
import { Devanagari } from 'lipitva/dist/scripts/brahmic/Devanagari'
import { Itrans } from 'lipitva/dist/scripts/roman/ITrans'

const registry = new ScriptsRegistry();
registry.register([Telugu, Devanagari, Itrans]);

// Now we can export our custom minimal instance of Lip from this module, and can use it through out our app.
export const customLip = new Lip(registry);
// module B
import { Script } from 'lipitva/dist/enum';
import { customLip } from './A';

const tVal = customLip.t({
    data: 'रामालयम्',
    from: Script.DEVANAGARI,
    to: Script.TELUGU,
}); // equals to రామాలయమ్

As lipitva allows efficient tree-shaking, in final bundle only those imported modules will be included. we can use functional tools like transliterate, transliterateElem directly too, instead of using OOP friendly Lip interface.

For further usage, and info refer code.

Development

Stack

  • Written in ES6 modules.
  • Written in strict TypeScript
  • Outputs in three module systems. commonJs in dist, ES6 in dist-esm, and umd bundles. rollup is used for umd-bundling
  • Strictly adheres to airbnb style guide. Before build, code should be validated against this style guide using ESLint (npm run lint). It is recommended to use ESLint plugin for IDEs like vscode. Thus they will lint code while you are coding, and provide auto formatting functionality.
  • Tape is used for testing. Read: 1🔗, 2🔗

Setup

clone the repository. And install (dev)dependencies.

npm install

Lint

npm run lint

Build

npm run build

Test

npm run test

Publish

npm publish --access public

See also