マイブーム@技術と生活

仕事や生活に関わる技術的なことを記述します。

.NET プログラマの JavaScript、Node.js 勉強

[Object]
JSON形式で表現するデータ型
キーと値のペア
{"name": "John Smith", "age": 33}

[ProtoBuf]

[RequestEnvelop、ResponseEnvelop]

[EventEmitter]
on('イベント名', function() { ... で実行

[var self = this;]

[module.exports]

[無名関数、即時関数、コールバック関数、ミドルウェア関数]
var abc = function (){...};
(function(){...})();
self.SetLocation = function (location, callback) {
 if (!location.name) {
  return callback(new Error('You should add a location name'));
 }
 callback(null, self.GetLocationCoords());
}
middleware function
関数を変数のように扱う
そのまま使用は、受取る変数
return は、実行後結果をイコールで戻す

MongoClient()
connect(url[, options], callback)
 Arguments:
  url (string) – connection url for MongoDB.
  [options] (object) – optional options for insert command
  callback (function) – this will be called after executing this method. The first parameter will contain the Error object if an error occured, or null otherwise. While the second parameter will contain the initialized db object or null if an error occured.
 Returns:
  null

 

[ArrayBuffer(typed array、JavaScript)、Buffer(Uint8Array、Node.js)]
Octet Stream

 

[forEach]
非同期になるきっかけは「処理に時間がかかるもの」ではなく、非同期メソッドを使うか否か
http://qiita.com/ishisak@github/items/cee2811a5a131d4ef946