Socket
Socket
Sign inDemoInstall

eastasianwidth

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eastasianwidth - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

22

eastasianwidth.js

@@ -1,3 +0,9 @@

var eaw = exports;
var eaw = {};
if ('undefined' == typeof module) {
window.eastasianwidth = eaw;
} else {
module.exports = eaw;
}
eaw.eastAsianWidth = function(character) {

@@ -272,1 +278,15 @@ var x = character.charCodeAt(0);

};
eaw.slice = function(text, start, end) {
start = start ? start : 0;
end = end ? end : 1;
var result = '';
for (var i = 0; i < text.length; i++) {
var char = text.charAt(i);
var eawLen = eaw.length(result + char);
if (eawLen >= 1 + start && eawLen < 1 + end) {
result += char
}
}
return result;
};

2

package.json
{
"name": "eastasianwidth",
"version": "0.1.0",
"version": "0.1.1",
"description": "Get East Asian Width from a character.",

@@ -5,0 +5,0 @@ "main": "eastasianwidth.js",

@@ -15,8 +15,19 @@ # East Asian Width

var eastasianwidth = require('eastasianwidth');
console.log(eastasianwidth.eastAsianWidth('₩')) // 'F'
console.log(eastasianwidth.eastAsianWidth('。')) // 'H'
console.log(eastasianwidth.eastAsianWidth('뀀')) // 'W'
console.log(eastasianwidth.eastAsianWidth('a')) // 'Na'
console.log(eastasianwidth.eastAsianWidth('①')) // 'A'
console.log(eastasianwidth.eastAsianWidth('ف')) // 'N'
var eaw = require('eastasianwidth');
console.log(eaw.eastAsianWidth('₩')) // 'F'
console.log(eaw.eastAsianWidth('。')) // 'H'
console.log(eaw.eastAsianWidth('뀀')) // 'W'
console.log(eaw.eastAsianWidth('a')) // 'Na'
console.log(eaw.eastAsianWidth('①')) // 'A'
console.log(eaw.eastAsianWidth('ف')) // 'N'
console.log(eaw.characterLength('₩')) // 2
console.log(eaw.characterLength('。')) // 1
console.log(eaw.characterLength('뀀')) // 2
console.log(eaw.characterLength('a')) // 1
console.log(eaw.characterLength('①')) // 2
console.log(eaw.characterLength('ف')) // 1
console.log(eaw.length('あいうえお')) // 10
console.log(eaw.length('abcdefg')) // 7
console.log(eaw.length('¢₩。ᅵㄅ뀀¢⟭a⊙①بف')) // 19
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