@tigerconnect/ref-union-di
Advanced tools
Comparing version 1.0.1-tc1 to 1.0.1-tc10
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.0.1-tc0 | ||
* @version 1.0.1-tc10 | ||
* @author Anna Henningsen <anna@addaleax.net> | ||
@@ -14,2 +14,4 @@ * @license MIT | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var assert = require('assert'); | ||
@@ -237,3 +239,3 @@ var _debug = require('debug'); | ||
module.exports = UnionDi; | ||
exports.UnionDi = UnionDi; | ||
//# sourceMappingURL=union.cjs.js.map |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.0.1-tc0 | ||
* @version 1.0.1-tc10 | ||
* @author Anna Henningsen <anna@addaleax.net> | ||
@@ -229,3 +229,3 @@ * @license MIT | ||
export { UnionDi as default }; | ||
export { UnionDi }; | ||
//# sourceMappingURL=union.esm.js.map |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 1.0.1-tc0 | ||
* @version 1.0.1-tc10 | ||
* @author Anna Henningsen <anna@addaleax.net> | ||
@@ -11,3 +11,3 @@ * @license MIT | ||
*/ | ||
import e from"assert";import n from"debug";const t=n("ref-union");function i(n){function i(){function n(i,r){if(!(this instanceof n))return new n(i,r);var f;if(t("creating new union instance"),Buffer.isBuffer(i)?(t("using passed-in Buffer instance to back the union",i),e(i.length>=n.size,"Buffer instance must be at least "+n.size+" bytes to back this untion type"),f=i,i=r):(t("creating new Buffer instance to back the union (size: %d)",n.size),f=new Buffer(n.size)),f.type=n,this["ref.buffer"]=f,i)for(var o in i)this[o]=i[o];n._instanceCreated=!0}t('defining new union "type"'),n.prototype=Object.create(c,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),n.defineProperty=s,n.toString=o,n.fields={},n.size=0,n.alignment=0,n.indirection=1,n.get=r,n.set=f;var i=arguments[0];return"object"==typeof i&&Object.keys(i).forEach((function(e){var t=i[e];n.defineProperty(e,t)})),n}function r(e,n){return t('Union "type" getter for buffer at offset',e,n),n>0&&(e=e.slice(n)),new this(e)}function f(e,n,i){t('Union "type" setter for buffer at offset',e,n,i),n>0&&(e=e.slice(n));var r=new this(e),f;if(i instanceof this)Object.keys(this.fields).forEach((function(e){r[e]=i[e]}));else for(var o in i)r[o]=i[o]}function o(){return"[UnionType]"}function s(i,r){t("defining new union type field",i),r=n.coerceType(r),e(!this._instanceCreated,"an instance of this Union type has already been created, cannot add new data members anymore"),e.equal("string",typeof i,'expected a "string" field name'),e(r&&/object|function/i.test(typeof r)&&"size"in r&&"indirection"in r,'expected a "type" object describing the field type: "'+r+'"'),e(!(i in this.prototype),'the field "'+i+'" already exists in this Union type'),Object.defineProperty(this.prototype,i,{enumerable:!0,configurable:!0,get:o,set:s});var f={type:r};function o(){return t('getting "%s" union field (length: %d)',i,r.size),n.get(this["ref.buffer"],0,r)}function s(e){return t('setting "%s" union field (length: %d)',i,r.size,e),n.set(this["ref.buffer"],0,e,r)}this.fields[i]=f,a(this)}function a(e){var i;e.size=0,e.alignment=0,Object.keys(e.fields).forEach((function(t){var i,r=e.fields[t].type,f=1===r.indirection?r.size:n.sizeof.pointer,o=r.alignment||n.alignof.pointer;r.indirection>1&&(o=n.alignof.pointer),e.alignment=Math.max(e.alignment,o),e.size=Math.max(e.size,f)}));var r=e.size%e.alignment;r>0&&(t("additional padding to the end of union:",e.alignment-r),e.size+=e.alignment-r)}var c={};return c["ref.buffer"]=n.NULL,c.ref=function e(){return this["ref.buffer"]},i}export{i as default}; | ||
import e from"assert";import n from"debug";const t=n("ref-union");function i(n){function i(){function n(i,r){if(!(this instanceof n))return new n(i,r);var f;if(t("creating new union instance"),Buffer.isBuffer(i)?(t("using passed-in Buffer instance to back the union",i),e(i.length>=n.size,"Buffer instance must be at least "+n.size+" bytes to back this untion type"),f=i,i=r):(t("creating new Buffer instance to back the union (size: %d)",n.size),f=new Buffer(n.size)),f.type=n,this["ref.buffer"]=f,i)for(var o in i)this[o]=i[o];n._instanceCreated=!0}t('defining new union "type"'),n.prototype=Object.create(c,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),n.defineProperty=s,n.toString=o,n.fields={},n.size=0,n.alignment=0,n.indirection=1,n.get=r,n.set=f;var i=arguments[0];return"object"==typeof i&&Object.keys(i).forEach((function(e){var t=i[e];n.defineProperty(e,t)})),n}function r(e,n){return t('Union "type" getter for buffer at offset',e,n),n>0&&(e=e.slice(n)),new this(e)}function f(e,n,i){t('Union "type" setter for buffer at offset',e,n,i),n>0&&(e=e.slice(n));var r=new this(e),f;if(i instanceof this)Object.keys(this.fields).forEach((function(e){r[e]=i[e]}));else for(var o in i)r[o]=i[o]}function o(){return"[UnionType]"}function s(i,r){t("defining new union type field",i),r=n.coerceType(r),e(!this._instanceCreated,"an instance of this Union type has already been created, cannot add new data members anymore"),e.equal("string",typeof i,'expected a "string" field name'),e(r&&/object|function/i.test(typeof r)&&"size"in r&&"indirection"in r,'expected a "type" object describing the field type: "'+r+'"'),e(!(i in this.prototype),'the field "'+i+'" already exists in this Union type'),Object.defineProperty(this.prototype,i,{enumerable:!0,configurable:!0,get:o,set:s});var f={type:r};function o(){return t('getting "%s" union field (length: %d)',i,r.size),n.get(this["ref.buffer"],0,r)}function s(e){return t('setting "%s" union field (length: %d)',i,r.size,e),n.set(this["ref.buffer"],0,e,r)}this.fields[i]=f,a(this)}function a(e){var i;e.size=0,e.alignment=0,Object.keys(e.fields).forEach((function(t){var i,r=e.fields[t].type,f=1===r.indirection?r.size:n.sizeof.pointer,o=r.alignment||n.alignof.pointer;r.indirection>1&&(o=n.alignof.pointer),e.alignment=Math.max(e.alignment,o),e.size=Math.max(e.size,f)}));var r=e.size%e.alignment;r>0&&(t("additional padding to the end of union:",e.alignment-r),e.size+=e.alignment-r)}var c={};return c["ref.buffer"]=n.NULL,c.ref=function e(){return this["ref.buffer"]},i}export{i as UnionDi}; | ||
//# sourceMappingURL=union.esm.min.js.map |
@@ -16,3 +16,3 @@ 'use strict'; | ||
export default function UnionDi (ref) { | ||
export function UnionDi (ref) { | ||
@@ -19,0 +19,0 @@ /** |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "1.0.1-tc1", | ||
"version": "1.0.1-tc10", | ||
"author": "Anna Henningsen <anna@addaleax.net>", | ||
@@ -28,12 +28,18 @@ "contributors": [ | ||
"module": "./dist/union.js", | ||
"types": "./dist/union.d.ts", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "run-s clean build:dist build:module build:rollup", | ||
"build": "run-s clean build:dist build:module build:rollup build:types", | ||
"build:dist": "shx mkdir -p dist", | ||
"build:module": "shx cp -f lib/union.js dist", | ||
"build:rollup": "rollup -c rollup.config.js", | ||
"build:types": "shx cp -f lib/union.d.ts dist", | ||
"clean": "shx rm -fr dist", | ||
"test": "node-gyp rebuild --directory test && mocha --expose-gc --reporter spec" | ||
"prepublishOnly": "run-s build", | ||
"test": "run-s build test:rebuild test:mocha", | ||
"test:rebuild": "node-gyp rebuild --directory test", | ||
"test:mocha": "mocha --expose-gc --reporter spec" | ||
}, | ||
"dependencies": { | ||
"@tigerconnect/ref-napi": "^4.0.0-tc2", | ||
"debug": "^4.3.1" | ||
@@ -49,3 +55,2 @@ }, | ||
"nyc": "^15.0.0", | ||
"ref-napi": "^3.0.2", | ||
"ref-struct-di": "^1.1.1", | ||
@@ -52,0 +57,0 @@ "rollup": "^2.67.2", |
Fork of [node-ffi-napi/ref-union-di](https://github.com/node-ffi-napi/ref-union-di). Changes: | ||
* Include patches from [alphacep/ref-union-di](https://github.com/alphacep/ref-union-di) | ||
* Convert to ESM module | ||
* Use rollup to provide CommonJS module | ||
* Add prepublishOnly script to ensure it's built before publishing | ||
* Change interface to `require('@tigerconnect/ref-union-di').UnionDi(ref)` | ||
* Bundle types from `@types/ref-union-di@1.0.0` | ||
* Switch `ref-napi` to `@tigerconnect/ref-napi` for node v16 support | ||
@@ -33,3 +39,3 @@ ref-union-di | ||
var ref = require('ref') | ||
var Union = require('@tigerconnect/ref-union-di')(ref) | ||
var Union = require('@tigerconnect/ref-union-di').UnionDi(ref) | ||
@@ -36,0 +42,0 @@ // a couple typedefs |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61188
11
12
632
90
2
+ Added@tigerconnect/ref-napi@4.0.0-tc8(transitive)
+ Added@types/node@22.7.9(transitive)
+ Addedget-symbol-from-current-process-h@1.0.2(transitive)
+ Addednode-addon-api@4.3.0(transitive)
+ Addednode-gyp-build@4.8.2(transitive)
+ Addedundici-types@6.19.8(transitive)