This is MK2
Hello World!
MK2's github pages
Home Page: http://fengmk2.github.com
Hello World!
目前还找不到具体是那段 js 代码写错了.
但是能写一个模拟重现代码:
var zlib = require('zlib');
var stream = zlib.createGzip();
stream.write('foo');
stream.close();
// Assertion failed: (!ctx->pending_close_ && "close is pending"), function Write, file ../src/node_zlib.cc, line 150.
stream.write('again');
尝新去给 node 提交 pr, 让这个判断放到 js 层面做.
^_^网站的音乐拿走了,见谅
最近在尝试改进 hsf 的 c++ 模块实现, 将 hessian 1.0 的 encode 和 decode 暴露出来给 js 调用.
因为需要保证 hsf 模块能在node 0.10.x 和 0.11.x 都能正常使用, 那么必须让此 c++ 模块有良好的代码兼容性.
吐血, c++ 新手还要考虑兼容性, 晴天霹雳.
org, 还好发现了 nan: A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10 and 0.11, and eventually 0.12.
codes at: nan-example
// function showTypes() {}
NAN_METHOD(showTypes) {
NanScope();
// var foo;
// var bar = null;
v8::Local<v8::Value> foo = NanUndefined();
v8::Local<v8::Value> bar = NanNull();
v8::Handle<v8::Value> bar2 = NanNull();
// var t = true;
// var f = false;
v8::Local<v8::Boolean> t = NanTrue();
v8::Local<v8::Boolean> f = NanFalse();
// var v1 = 100;
// var v2 = 1024.123;
// var v3 = 0.123456789;
v8::Local<v8::Number> v1 = NanNew<v8::Number>(100);
v8::Local<v8::Number> v2 = NanNew<v8::Number>(1024.123);
v8::Handle<v8::Number> v3 = NanNew<v8::Number>(0.123456789);
// var s1 = '';
// var s2 = 'hello world';
// var s3 = 'no ascii 还有中文';
v8::Local<v8::String> s1 = NanNew<v8::String>("");
v8::Local<v8::String> s2 = NanNew<v8::String>("hello world");
v8::Local<v8::String> s3 = NanNew<v8::String>("no ascii 还有中文");
// var now = new Date(1399273631054);
double timestamp = 1399273631054;
v8::Local<v8::Date> now = NanNew<v8::Date>(timestamp);
// var result = {};
// result['undefined'] = foo;
// result['null'] = bar;
// result['null2'] = bar2;
// result['true'] = t;
// result['false'] = f;
// result['v1'] = v1;
// result['v2'] = v2;
// result['v3'] = v3;
// result['s1'] = s1;
// result['s2'] = s2;
// result['s3'] = s3;
// result.now = now;
v8::Local<v8::Object> result = NanNew<v8::Object>();
result->Set(NanSymbol("undefined"), foo);
result->Set(NanSymbol("null"), bar);
result->Set(NanSymbol("null2"), bar2);
result->Set(NanSymbol("true"), t);
result->Set(NanSymbol("false"), f);
result->Set(NanSymbol("v1"), v1);
result->Set(NanSymbol("v2"), v2);
result->Set(NanSymbol("v3"), v3);
result->Set(NanSymbol("s1"), s1);
result->Set(NanSymbol("s2"), s2);
result->Set(NanSymbol("s3"), s3);
result->Set(NanSymbol("now"), now);
// var arr = [];
// arr.push(foo);
// arr.push(bar);
// arr.push(bar2);
// arr.push(t);
// arr.push(f);
// arr.push(v1);
// arr.push(v2);
// arr.push(v3);
// arr.push(s1);
// arr.push(s2);
// arr.push(s3);
// arr.push(now);
int index = 0;
v8::Local<v8::Array> arr = NanNew<v8::Array>();
arr->Set(index++, foo);
arr->Set(index++, bar);
arr->Set(index++, bar2);
arr->Set(index++, t);
arr->Set(index++, f);
arr->Set(index++, v1);
arr->Set(index++, v2);
arr->Set(index++, v3);
arr->Set(index++, s1);
arr->Set(index++, s2);
arr->Set(index++, s3);
arr->Set(index++, now);
result->Set(NanSymbol("array"), arr);
result->Set(NanSymbol("array-length"), NanNew<v8::Number>(arr->Length()));
NanReturnValue(result);
}
Number vs NumberObject
哈哈, 看起来这是一个很好的地方.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.