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

wcwidth.js

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wcwidth.js - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

INSTALL.md

8

package.json
{
"name": "wcwidth.js",
"version": "0.0.1",
"version": "0.0.2",
"description": "A JavaScript porting of C's wcwidth() and wcswidth()",

@@ -14,7 +14,7 @@ "author": {

"repository": {
"type": "hg",
"url": "http://code.woong.org/hg/wcwidth.js"
"type": "git",
"url": "https://github.com/mycoboco/wcwidth.js.git"
},
"bugs": {
"url": "http://code.woong.org/wcwidth.js/trac",
"url": "https://github.com/mycoboco/wcwidth.js/issues",
"email": "woong.jun@gmail.com"

@@ -21,0 +21,0 @@ },

@@ -1,18 +0,18 @@

wcwidth.js: A JavaScript Porting of Markus Kuhn's wcwidth() Implementation
==========================================================================
wcwidth.js: A JavaScript Porting of Markus Kuhn's wcwidth() Implementation
==========================================================================
wcwidth.js is a simple JavaScript porting of wcwidth() implemented in C by
Markus Kuhn (the original implementation can be found on
http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c). wcwidth() and its string
version, wcswidth() are defined by IEEE Std 1002.1-2001, a.k.a. POSIX.1-2001,
and return the number of columns used to represent the given wide character
and string. Markus's implementation assumes the wide character given to those
functions to be encoded in ISO 10646, which is almost true for JavaScript's
characters.
`wcwidth.js` is a simple JavaScript porting of `wcwidth()` implemented in C
[by Markus Kuhn](http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c).
For convenience, wcwidth.js sets the getter of the property named 'wcwidth'
for the String type. You don't need to invoke a function to get the width of
strings, but inspecting the wcwidth property is enough. The following code
snippet shows how to use wcwidth.js:
`wcwidth()` and its string version, `wcswidth()` are defined by IEEE Std
1002.1-2001, a.k.a. POSIX.1-2001, and return the number of columns used to
represent the given wide character and string. Markus's implementation assumes
the wide character given to those functions to be encoded in ISO 10646, which
is almost true for JavaScript's characters.
For convenience, `wcwidth.js` sets the getter of the property named `wcwidth`
for the string type. You don't need to invoke a function to get the width of
strings, but inspecting the `wcwidth` property is enough. The following code
snippet shows how to use `wcwidth.js`:
var wcwidth = require('wcwidth')({

@@ -27,8 +27,8 @@ nul: 0,

The argument '{ nul: 0, control: -1 }' (which are the default values, in fact)
tells wcwidth.js to return 0 for the NUL character and -1 for non-printable
control characters. Setting a negative value to 'nul' or 'control' makes the
wcwidth property set to -1 for any string that contains NUL or control
characters respectively. If you plan to replace each control character with,
say, '???' when printing, you can 'require' wcwidth.js as follows:
The argument `{ nul: 0, control: -1 }` (which are the default values, in fact)
tells `wcwidth.js` to return 0 for the NUL character and -1 for non-printable
control characters. Setting a negative value to `nul` or `control` makes the
`wcwidth` property set to -1 for any string that contains NUL or control
characters respectively. If you plan to replace each control character with,
say, `???` when printing, you can 'require' `wcwidth.js` as follows:

@@ -42,5 +42,5 @@ var wcwidth = require('wcwidth')({

wcwidth.js also provides a methods. Since JavaScript has no character type, it
is meaningless to have two versions while POSIX does for C. The method also
accepts a code value that can be obtained by the charCodeAt() method.
`wcwidth.js` also provides a methods. Since JavaScript has no character type,
it is meaningless to have two versions while POSIX does for C. The method also
accepts a code value that can be obtained by the `charCodeAt()` method.

@@ -51,5 +51,6 @@ console.log(wcwidth('한')); // prints 2

For the copyright issues, see the accompanying LICENSE file.
`INSTALL.md` explains how to build and install the library. For the copyright
issues, see the accompanying `LICENSE.md` file.
If you have a question or suggestion, do not hesitate to contact me via email
<woong.jun@gmail.com> or web <http://code.woong.org/>.
If you have a question or suggestion, do not hesitate to contact me via email
(woong.jun at gmail.com) or web (http://code.woong.org/).

@@ -214,2 +214,4 @@ /*

assert(_.isUndefined(option) || _.isObject(option));
option = _.extend({

@@ -216,0 +218,0 @@ nul: 0,

Sorry, the diff of this file is not supported yet

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