k2hash 1.1.34 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +106 -0
- package/build/cjs/index.js +296 -0
- package/build/esm/index.js +293 -0
- package/buildutils/make_node_prebuild_variables.sh +359 -0
- package/buildutils/node_prebuild.sh +371 -0
- package/buildutils/node_prebuild_install.sh +307 -0
- package/index.js +4 -1
- package/index.mjs +154 -0
- package/package.json +76 -20
- package/src/index.ts +378 -0
- package/src/k2h_cbs.cc +27 -41
- package/src/k2h_cbs.h +17 -13
- package/src/k2h_common.h +1 -1
- package/src/k2h_keyqueue.cc +513 -339
- package/src/k2h_keyqueue.h +38 -30
- package/src/k2h_keyqueue_async.h +222 -184
- package/src/k2h_queue.cc +483 -304
- package/src/k2h_queue.h +38 -30
- package/src/k2h_queue_async.h +218 -173
- package/src/k2h_shm.cc +1963 -1221
- package/src/k2h_shm.h +109 -104
- package/src/k2h_shm_async.h +722 -560
- package/src/k2hash.cc +22 -8
- package/src/k2hkeyqueue.cc +21 -8
- package/src/k2hqueue.cc +21 -8
- package/types/index.d.ts +570 -0
- package/ChangeLog +0 -137
- package/src/binding.gyp +0 -146
package/src/k2hash.cc
CHANGED
|
@@ -18,25 +18,39 @@
|
|
|
18
18
|
* REVISION:
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
#include <napi.h>
|
|
21
22
|
#include "k2h_shm.h"
|
|
22
23
|
|
|
23
|
-
using namespace v8 ;
|
|
24
|
-
|
|
25
24
|
//---------------------------------------------------------
|
|
26
25
|
// k2hash node object
|
|
27
26
|
//---------------------------------------------------------
|
|
28
|
-
|
|
27
|
+
// [NOTE]
|
|
28
|
+
// The logic for receiving arguments when switching to N-API has been removed.
|
|
29
|
+
// This is because the arguments were not used in the first place and did not
|
|
30
|
+
// need to be defined.
|
|
31
|
+
//
|
|
32
|
+
Napi::Value CreateObject(const Napi::CallbackInfo& info)
|
|
29
33
|
{
|
|
30
|
-
|
|
34
|
+
Napi::Env env = info.Env();
|
|
35
|
+
return K2hNode::NewInstance(env); // always no arguments.
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
Napi::Object InitAll(Napi::Env env, Napi::Object exports)
|
|
34
39
|
{
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
// Class registration (creating a constructor)
|
|
41
|
+
K2hNode::Init(env, exports); // この中で constructor を作って Persistent に保存している想定
|
|
42
|
+
|
|
43
|
+
// Create a factory function that returns module.exports
|
|
44
|
+
Napi::Function createFn = Napi::Function::New(env, CreateObject, "k2hash");
|
|
45
|
+
|
|
46
|
+
// Allow to use "require('k2hash').K2hNode"
|
|
47
|
+
createFn.Set("K2hNode", K2hNode::constructor.Value());
|
|
48
|
+
|
|
49
|
+
// Replace module.exports with this function (does not break existing "require('k2hash')()".)
|
|
50
|
+
return createFn;
|
|
37
51
|
}
|
|
38
52
|
|
|
39
|
-
|
|
53
|
+
NODE_API_MODULE(k2hash, InitAll)
|
|
40
54
|
|
|
41
55
|
/*
|
|
42
56
|
* Local variables:
|
package/src/k2hkeyqueue.cc
CHANGED
|
@@ -20,23 +20,36 @@
|
|
|
20
20
|
|
|
21
21
|
#include "k2h_keyqueue.h"
|
|
22
22
|
|
|
23
|
-
using namespace v8 ;
|
|
24
|
-
|
|
25
23
|
//---------------------------------------------------------
|
|
26
24
|
// k2hkeyqueue node object
|
|
27
25
|
//---------------------------------------------------------
|
|
28
|
-
|
|
26
|
+
Napi::Value CreateObject(const Napi::CallbackInfo& info)
|
|
29
27
|
{
|
|
30
|
-
|
|
28
|
+
Napi::Env env = info.Env();
|
|
29
|
+
|
|
30
|
+
if(0 < info.Length()){
|
|
31
|
+
return K2hKeyQueue::NewInstance(env, info[0]);
|
|
32
|
+
}else{
|
|
33
|
+
return K2hKeyQueue::NewInstance(env);
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
Napi::Object InitAll(Napi::Env env, Napi::Object exports)
|
|
34
38
|
{
|
|
35
|
-
K2hKeyQueue::
|
|
36
|
-
|
|
39
|
+
// Register class / create constructor (store in K2hKeyQueue::constructor)
|
|
40
|
+
K2hKeyQueue::Init(env, exports);
|
|
41
|
+
|
|
42
|
+
// Create factory function to be assigned to module.exports
|
|
43
|
+
Napi::Function createFn = Napi::Function::New(env, CreateObject, "k2hkeyqueue");
|
|
44
|
+
|
|
45
|
+
// Attach constructor for compatibility (require('k2hkeyqueue').K2hKeyQueue)
|
|
46
|
+
createFn.Set("K2hKeyQueue", K2hKeyQueue::constructor.Value());
|
|
47
|
+
|
|
48
|
+
// Return factory function as module.exports
|
|
49
|
+
return createFn;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
NODE_API_MODULE(k2hkeyqueue, InitAll)
|
|
40
53
|
|
|
41
54
|
/*
|
|
42
55
|
* Local variables:
|
package/src/k2hqueue.cc
CHANGED
|
@@ -20,23 +20,36 @@
|
|
|
20
20
|
|
|
21
21
|
#include "k2h_queue.h"
|
|
22
22
|
|
|
23
|
-
using namespace v8 ;
|
|
24
|
-
|
|
25
23
|
//---------------------------------------------------------
|
|
26
24
|
// k2hqueue node object
|
|
27
25
|
//---------------------------------------------------------
|
|
28
|
-
|
|
26
|
+
Napi::Value CreateObject(const Napi::CallbackInfo& info)
|
|
29
27
|
{
|
|
30
|
-
|
|
28
|
+
Napi::Env env = info.Env();
|
|
29
|
+
|
|
30
|
+
if(0 < info.Length()){
|
|
31
|
+
return K2hQueue::NewInstance(env, info[0]);
|
|
32
|
+
}else{
|
|
33
|
+
return K2hQueue::NewInstance(env);
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
Napi::Object InitAll(Napi::Env env, Napi::Object exports)
|
|
34
38
|
{
|
|
35
|
-
K2hQueue::
|
|
36
|
-
|
|
39
|
+
// Register class / create constructor (store in K2hQueue::constructor)
|
|
40
|
+
K2hQueue::Init(env, exports);
|
|
41
|
+
|
|
42
|
+
// Create factory function to be assigned to module.exports
|
|
43
|
+
Napi::Function createFn = Napi::Function::New(env, CreateObject, "k2hqueue");
|
|
44
|
+
|
|
45
|
+
// Attach constructor for compatibility (require('k2hqueue').K2hQueue)
|
|
46
|
+
createFn.Set("K2hQueue", K2hQueue::constructor.Value());
|
|
47
|
+
|
|
48
|
+
// Return factory function as module.exports
|
|
49
|
+
return createFn;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
NODE_API_MODULE(k2hqueue, InitAll)
|
|
40
53
|
|
|
41
54
|
/*
|
|
42
55
|
* Local variables:
|