Skip to content

Commit 5d660dd

Browse files
committed
added nan versions
1 parent bd91f06 commit 5d660dd

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

1_hello_world/nan/binding.gyp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name": "hello",
5+
"sources": [ "hello.cc" ],
6+
"include_dirs": [
7+
"<!(node -e \"require('nan')\")"
8+
]
9+
}
10+
]
11+
}

1_hello_world/nan/hello.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <nan.h>
2+
3+
using namespace v8;
4+
5+
NAN_METHOD(Method) {
6+
NanScope();
7+
NanReturnValue(String::New("world"));
8+
}
9+
10+
void Init(Handle<Object> exports) {
11+
exports->Set(String::NewSymbol("hello"),
12+
FunctionTemplate::New(Method)->GetFunction());
13+
}
14+
15+
NODE_MODULE(hello, Init)

1_hello_world/nan/hello.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var addon = require('./build/Release/hello');
2+
3+
console.log(addon.hello()); // 'world'

1_hello_world/nan/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "hello_world",
3+
"version": "0.0.0",
4+
"description": "Node.js Addons Example #1",
5+
"main": "hello.js",
6+
"private": true,
7+
"dependencies": {
8+
"nan": "~0.6.0"
9+
},
10+
"scripts": {
11+
"test": "node hello.js"
12+
},
13+
"gypfile": true
14+
}

0 commit comments

Comments
 (0)