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

ilib-casemapper

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ilib-casemapper

A locale-sensitive class to map strings to upper- or lower-case

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ilib-casemapper

Map a string to upper- or lower-case locale-sensitively.

Many people don't realize that case mapping is a locale-sensitive operation. The fact is, what the upper-case version of a particular letter is depends on who you ask!

Installation

npm install ilib-casemapper

or

yarn add ilib-casemapper

Upper- or Lower-casing a Letter

To map the case of a letter, you first create an instance of the CaseMapper class. By default, this will use the mappings for English.

Here is how you would map a letter using the Turkish rules:

ES2015:

var CaseMapper = require("ilib-casemapper");
var cm = new CaseMapper({locale: "tr-TR"});

var upper = cm.map('i'); // "upper" should now contain "İ"

ES6:

import CaseMapper from "ilib-casemapper";
const cm = new CaseMapper({locale: "tr-TR"});

const upper = cm.map('i'); // "upper" should now contain "İ"

In general, you should be able to use the case mapper in older Javascript engines by requiring it, or in modern Javascript engines by importing it. The package was built to be able to support both. From here on, we will only give modern JS examples.

Here is how you use the case mapper to lower:

import CaseMapper from "ilib-casemapper";
const cm = new CaseMapper({
    locale: "tr-TR",
    direction: "lower"
});

const upper = cm.map('İ'); // "upper" should now contain "i"

Full documentation: CaseMapper class

License

Copyright © 2023, JEDLSoft

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Release Notes

v1.0.0

  • Code taken from ilib 14.19.0 and converted to an ES6 module.
  • Use babel to transpile it back to ES2015 so it can be used in either ES215 or ES6 code

Keywords

FAQs

Package last updated on 25 Jan 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