eastasianwidth
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -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; | ||
}; |
{ | ||
"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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15297
351
33