LoginSignup
0
0

More than 5 years have passed since last update.

nodejs note

Last updated at Posted at 2017-09-19

base64

standard lib.

var enc = new Buffer("日本").toString('base64')
var dec = new Buffer(enc, 'base64').toString()

gzip

standard lib.

var zlib = require('zlib');
var bin = zlib.gzipSync("imaoka-san");
var dec = zlib.gunzipSync(bin).toString()

Buffer

https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_buffer
- String = immutable & not byte-array
- Buffer = mutable & byte-array

from fs / encoding

var ret = fs.readFileSync("./cp932.txt");
// ret is Buffer, raw bin-array
var iconv = require('iconv-lite');

// decord bin-array(cp932) to json strings
var js_str = iconv.decode(ret,'CP932');
// json strings to utf8
js_str = iconv.encode(cp932,'UTF8').toString();

npx ?

  • ./node_modules/.bin/(package-name)
  • $(npm bin)/(package-name)
  • Write npm-scripts @ package.json

npx more cool!

npm install pm2
npx pm2

  Usage: pm2 [cmd] app


  Options:

    -V, --version                    output the version number
    -v --version                     get version

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0