From 0b2a68a45cd91385220ae2eb18784f76c33bdd32 Mon Sep 17 00:00:00 2001 From: Janealter Date: Wed, 25 Sep 2019 22:04:02 +0300 Subject: [PATCH 1/9] Updated .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 507fbe1..c63d6df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules /test/build /?.js +/package-lock.json From 34a2280c541b5baa684de3dfd97b2493e4fd04be Mon Sep 17 00:00:00 2001 From: Janealter Date: Wed, 25 Sep 2019 22:05:10 +0300 Subject: [PATCH 2/9] 'ref' replaced by 'ref-napi --- lib/array.js | 2 +- package.json | 2 +- test/array.js | 2 +- test/native_tests.cc | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/array.js b/lib/array.js index b86ae13..08223a2 100644 --- a/lib/array.js +++ b/lib/array.js @@ -3,7 +3,7 @@ * Module dependencies. */ -var _ref = require('ref') +var _ref = require('ref-napi') var assert = require('assert') var debug = require('debug')('ref:array') var ArrayIndex = require('array-index') diff --git a/package.json b/package.json index 3422913..7575672 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "array-index": "1", "debug": "2", - "ref": "1" + "ref-napi": "^1.4.2" }, "devDependencies": { "bindings": "1", diff --git a/test/array.js b/test/array.js index 60311b8..23d0c6c 100644 --- a/test/array.js +++ b/test/array.js @@ -1,6 +1,6 @@ var assert = require('assert') - , ref = require('ref') + , ref = require('ref-napi') , ArrayType = require('../') , bindings = require('bindings')({ module_root: __dirname, bindings: 'native_tests' }) diff --git a/test/native_tests.cc b/test/native_tests.cc index 2074d72..3f1add0 100644 --- a/test/native_tests.cc +++ b/test/native_tests.cc @@ -8,13 +8,13 @@ namespace { NAN_METHOD(ArrayAbs) { int *arr = reinterpret_cast(Buffer::Data(info[0].As())); - uint32_t length = info[1]->Uint32Value(); + uint32_t length = info[1]->Uint32Value(Nan::GetCurrentContext()).FromJust(); for (uint32_t i = 0; i < length; i++) { *(arr + i) = abs(arr[i]); } } -void Initialize(v8::Handle target) { +void Initialize(v8::Local target) { Nan::HandleScope scope; Nan::SetMethod(target, "arrayAbs", ArrayAbs); } From d00483b57e6968766dc60b80e4cc9258419fcc4e Mon Sep 17 00:00:00 2001 From: Janealter Date: Thu, 26 Sep 2019 12:25:50 +0300 Subject: [PATCH 3/9] Changed CI/CD configs --- .travis.yml | 4 ++-- appveyor.yml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c5c65ab..d7b97bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,11 @@ addons: language: node_js node_js: - - "4" - - "5" - "6" - "7" - "8" + - "10" + - "12" install: - PATH="`npm bin`:`npm bin -g`:$PATH" diff --git a/appveyor.yml b/appveyor.yml index c5e4bf1..4a26cc1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,13 +3,14 @@ # Test against these versions of Node.js. environment: # Visual Studio Version - MSVS_VERSION: 2013 + MSVS_VERSION: 2015 # Test against these versions of Node.js and io.js matrix: - - nodejs_version: "4" - nodejs_version: "6" - nodejs_version: "7" - nodejs_version: "8" + - nodejs_version: "10" + - nodejs_version: "12" platform: - x86 From ede1e5eb40ff7a3a33fc66da613962d2ab90f6dc Mon Sep 17 00:00:00 2001 From: Janealter Date: Thu, 26 Sep 2019 12:27:25 +0300 Subject: [PATCH 4/9] Changed readme and package.json --- README.md | 14 +++++++------- package.json | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f6d1d89..efb31b1 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -ref-array +ref-array-napi ========= ### Create C typed "array" instances on top of Buffers -[![Build Status](https://secure.travis-ci.org/TooTallNate/ref-array.svg)](https://travis-ci.org/TooTallNate/ref-array) -[![Build Status](https://ci.appveyor.com/api/projects/status/auxk791h56hbughd?svg=true)](https://ci.appveyor.com/project/TooTallNate/ref-array) +[![Build Status](https://secure.travis-ci.org/Janealter/ref-array-napi.svg)](https://travis-ci.org/Janealter/ref-array-napi) +[![Build Status](https://ci.appveyor.com/api/projects/status/gibqc0mg6dkdn9o4?svg=true)](https://ci.appveyor.com/project/Janealter/ref-array-napi) This module offers an "array" implementation on top of Node.js Buffers using -the ref "type" interface. +the ref "type" interface. Supports Node 6, 7, 8, 10, 12. Installation ------------ @@ -14,7 +14,7 @@ Installation Install with `npm`: ``` bash -$ npm install ref-array +$ npm install ref-array-napi ``` @@ -24,8 +24,8 @@ Examples #### Basic usage ``` js -var ref = require('ref') -var ArrayType = require('ref-array') +var ref = require('ref-napi') +var ArrayType = require('ref-array-napi') // typedef var int = ref.types.int diff --git a/package.json b/package.json index 7575672..7767de6 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "name": "ref-array", - "description": "Create C \"array\" instances on top of Buffers", + "name": "ref-array-napi", + "description": "Create C \"array\" instances on top of Buffers. Supports Node 6, 7, 8, 10, 12.", "keywords": [ "array", "ref" ], "version": "1.2.0", - "author": "Nathan Rajlich (http://tootallnate.net)", + "author": "Nathan Rajlich (http://tootallnate.net) & Janealter", "repository": { "type": "git", - "url": "git://github.com/TooTallNate/ref-array.git" + "url": "git://github.com/Janealter/ref-array-napi.git" }, "main": "./lib/array.js", "license": "MIT", From f1993c97ecd20fd9caa1a85101fa630efc50c6da Mon Sep 17 00:00:00 2001 From: Janealter Date: Wed, 29 Apr 2020 15:05:02 +0300 Subject: [PATCH 5/9] Fixed Travis badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efb31b1..64b06d7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ref-array-napi ========= ### Create C typed "array" instances on top of Buffers -[![Build Status](https://secure.travis-ci.org/Janealter/ref-array-napi.svg)](https://travis-ci.org/Janealter/ref-array-napi) +[![Build Status](https://travis-ci.org/Janealter/ref-array-napi.svg)](https://travis-ci.org/Janealter/ref-array-napi) [![Build Status](https://ci.appveyor.com/api/projects/status/gibqc0mg6dkdn9o4?svg=true)](https://ci.appveyor.com/project/Janealter/ref-array-napi) From 7bb46680c42e4e186cec2fe22fcf7db70d99e9ca Mon Sep 17 00:00:00 2001 From: Alexander Gusev Date: Thu, 23 Apr 2020 07:44:54 +0300 Subject: [PATCH 6/9] Added typescript definitions file --- index.d.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..74e6ceb --- /dev/null +++ b/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for ref-array-napi +// Project: https://github.com/Janealter/ref-array-napi +// Definitions by: goooseman +// Used definitions by: Paul Loyd +// TypeScript Version: 3.7 + +import ref = require('ref-napi'); + +interface ArrayTypeInstance { + [i: number]: T; + length: number; + toArray(): T[]; + toJSON(): T[]; + inspect(): string; + buffer: Buffer; + ref(): Buffer; +} + +interface ArrayType extends ref.Type { + BYTES_PER_ELEMENT: number; + fixedLength: number; + /** The reference to the base type. */ + type: ref.Type; + + /** + * Accepts a Buffer instance that should be an already-populated with data + * for the ArrayType. The "length" of the Array is determined by searching + * through the buffer's contents until an aligned NULL pointer is encountered. + */ + untilZeros(buffer: Buffer): ArrayTypeInstance; + + new (length?: number): ArrayTypeInstance; + new (data: number[], length?: number): ArrayTypeInstance; + new (data: Buffer, length?: number): ArrayTypeInstance; + (length?: number): ArrayTypeInstance; + (data: number[], length?: number): ArrayTypeInstance; + (data: Buffer, length?: number): ArrayTypeInstance; +} + +/** + * The array type meta-constructor. + * The returned constructor's API is highly influenced by the WebGL + * TypedArray API. + */ +declare const ArrayType: { + (type: ref.Type, length?: number): ArrayType; + (type: string, length?: number): ArrayType; +}; + +export = ArrayType; From 7c75cdeac2aed4f5669424be08704a61b43cabd8 Mon Sep 17 00:00:00 2001 From: Janealter Date: Fri, 1 May 2020 18:26:52 +0300 Subject: [PATCH 7/9] Bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7767de6..7ba327b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "array", "ref" ], - "version": "1.2.0", + "version": "1.2.1", "author": "Nathan Rajlich (http://tootallnate.net) & Janealter", "repository": { "type": "git", From d0ba66bd4728dcc314510102438395f6f60c6ff3 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Sat, 20 Feb 2021 13:22:20 +0100 Subject: [PATCH 8/9] Bump ref-napi to 3.0.1 --- .travis.yml | 1 + appveyor.yml | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7b97bf..96408a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ node_js: - "8" - "10" - "12" + - "14" install: - PATH="`npm bin`:`npm bin -g`:$PATH" diff --git a/appveyor.yml b/appveyor.yml index 4a26cc1..cf9d979 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,6 +11,7 @@ environment: - nodejs_version: "8" - nodejs_version: "10" - nodejs_version: "12" + - nodejs_version: "14" platform: - x86 diff --git a/package.json b/package.json index 7ba327b..92916ab 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "array-index": "1", "debug": "2", - "ref-napi": "^1.4.2" + "ref-napi": "^3.0.1" }, "devDependencies": { "bindings": "1", From 8065101c708a32354151e203a15cc2873e4b8b42 Mon Sep 17 00:00:00 2001 From: Janealter Date: Thu, 1 Apr 2021 22:36:28 +0300 Subject: [PATCH 9/9] Bumped version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92916ab..07b6b3f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "array", "ref" ], - "version": "1.2.1", + "version": "1.2.2", "author": "Nathan Rajlich (http://tootallnate.net) & Janealter", "repository": { "type": "git",