node-opcua-factory
Advanced tools
Comparing version 2.0.0-alpha.19 to 2.0.0-alpha.21
@@ -39,3 +39,3 @@ "use strict"; | ||
case types_1.FieldCategory.complex: { | ||
node_opcua_assert_1.default(field.category === types_1.FieldCategory.complex); | ||
node_opcua_assert_1.assert(field.category === types_1.FieldCategory.complex); | ||
if (!field.fieldTypeConstructor) { | ||
@@ -69,3 +69,3 @@ field.fieldTypeConstructor = factories_factories_1.getStructureTypeConstructor(field.fieldType); | ||
} | ||
node_opcua_assert_1.default(_.isArray(value)); | ||
node_opcua_assert_1.assert(_.isArray(value)); | ||
const v = []; | ||
@@ -87,3 +87,3 @@ const m = Math.min(_nbElements, value.length); | ||
} | ||
node_opcua_assert_1.default(self); | ||
node_opcua_assert_1.assert(self); | ||
const fieldType = field.fieldType; | ||
@@ -219,3 +219,3 @@ const fieldName = field.name; | ||
const enumeration = factories_enumerations_1.getEnumeration(field.fieldType); | ||
node_opcua_assert_1.default(enumeration !== null); | ||
node_opcua_assert_1.assert(enumeration !== null); | ||
if (field.isArray) { | ||
@@ -295,3 +295,3 @@ options[field.name] = f.map((value) => enumeration.enumValues[value.toString()]); | ||
isValid() { | ||
node_opcua_assert_1.default(this.schema); | ||
node_opcua_assert_1.assert(this.schema); | ||
if (this.schema.isValid) { | ||
@@ -351,3 +351,3 @@ return this.schema.isValid(this); | ||
toJSON() { | ||
node_opcua_assert_1.default(this.schema); | ||
node_opcua_assert_1.assert(this.schema); | ||
if (this.schema.toJSON) { | ||
@@ -357,3 +357,3 @@ return this.schema.toJSON.apply(this, arguments); | ||
else { | ||
node_opcua_assert_1.default(this.schema); | ||
node_opcua_assert_1.assert(this.schema); | ||
const schema = this.schema; | ||
@@ -401,3 +401,3 @@ const options = {}; | ||
function _visitSchemaChain(self, schema, options, func, extraData) { | ||
node_opcua_assert_1.default(_.isFunction(func)); | ||
node_opcua_assert_1.assert(_.isFunction(func)); | ||
// apply also construct to baseType schema first | ||
@@ -404,0 +404,0 @@ const baseSchema = factories_structuredTypeSchema_1.get_base_schema(schema); |
@@ -47,7 +47,7 @@ "use strict"; | ||
} | ||
node_opcua_assert_1.default(_.isFunction(t.decode)); | ||
node_opcua_assert_1.assert(_.isFunction(t.decode)); | ||
const encodeFunc = schema.encode || t.encode; | ||
node_opcua_assert_1.default(_.isFunction(encodeFunc)); | ||
node_opcua_assert_1.assert(_.isFunction(encodeFunc)); | ||
const decodeFunc = schema.decode || t.decode; | ||
node_opcua_assert_1.default(_.isFunction(decodeFunc)); | ||
node_opcua_assert_1.assert(_.isFunction(decodeFunc)); | ||
const defaultValue = (schema.defaultValue === undefined) ? t.defaultValue : schema.defaultValue; | ||
@@ -54,0 +54,0 @@ // assert(_.isFunction(defaultValue)); |
@@ -10,3 +10,3 @@ "use strict"; | ||
function _self_encode(constructor) { | ||
node_opcua_assert_1.default(_.isFunction(constructor)); | ||
node_opcua_assert_1.assert(_.isFunction(constructor)); | ||
return (value, stream) => { | ||
@@ -20,3 +20,3 @@ if (!value || !value.encode) { | ||
function _self_decode(constructor) { | ||
node_opcua_assert_1.default(_.isFunction(constructor)); | ||
node_opcua_assert_1.assert(_.isFunction(constructor)); | ||
return (stream) => { | ||
@@ -29,3 +29,3 @@ const value = new constructor(); | ||
function _self_coerce(constructor) { | ||
node_opcua_assert_1.default(_.isFunction(constructor)); | ||
node_opcua_assert_1.assert(_.isFunction(constructor)); | ||
return (value) => { | ||
@@ -37,3 +37,3 @@ const obj = new constructor(value); | ||
function registerSpecialVariantEncoder(constructor) { | ||
node_opcua_assert_1.default(_.isFunction(constructor)); | ||
node_opcua_assert_1.assert(_.isFunction(constructor)); | ||
const name = constructor.prototype.schema.name; | ||
@@ -40,0 +40,0 @@ factories_builtin_types_1.registerType({ |
@@ -37,10 +37,10 @@ "use strict"; | ||
} | ||
node_opcua_assert_1.default(value instanceof Buffer); | ||
node_opcua_assert_1.assert(value instanceof Buffer); | ||
return value.toString("base64"); | ||
} | ||
function encodeAny(value, stream) { | ||
node_opcua_assert_1.default(false, "type 'Any' cannot be encoded"); | ||
node_opcua_assert_1.assert(false, "type 'Any' cannot be encoded"); | ||
} | ||
function decodeAny(stream) { | ||
node_opcua_assert_1.default(false, "type 'Any' cannot be decoded"); | ||
node_opcua_assert_1.assert(false, "type 'Any' cannot be decoded"); | ||
} | ||
@@ -201,3 +201,3 @@ function encodeNull(value, stream) { | ||
function registerType(schema) { | ||
node_opcua_assert_1.default(typeof schema.name === "string"); | ||
node_opcua_assert_1.assert(typeof schema.name === "string"); | ||
if (!_.isFunction(schema.encode)) { | ||
@@ -226,4 +226,4 @@ throw new Error("schema " + schema.name + " has no encode function"); | ||
const typeSchema = _defaultTypeMap.get(name); | ||
node_opcua_assert_1.default(typeSchema); | ||
node_opcua_assert_1.default(typeSchema instanceof types_1.TypeSchemaBase); | ||
node_opcua_assert_1.assert(typeSchema); | ||
node_opcua_assert_1.assert(typeSchema instanceof types_1.TypeSchemaBase); | ||
return typeSchema; | ||
@@ -254,3 +254,3 @@ } | ||
} | ||
node_opcua_assert_1.default(typeof dataTypeName === "string", "findBuiltInType : expecting a string " + dataTypeName); | ||
node_opcua_assert_1.assert(typeof dataTypeName === "string", "findBuiltInType : expecting a string " + dataTypeName); | ||
const t = _defaultTypeMap.get(dataTypeName); | ||
@@ -257,0 +257,0 @@ if (!t) { |
@@ -22,4 +22,4 @@ "use strict"; | ||
options.typedEnum = typedEnum; | ||
node_opcua_assert_1.default(!options.encode || _.isFunction(options.encode)); | ||
node_opcua_assert_1.default(!options.decode || _.isFunction(options.decode)); | ||
node_opcua_assert_1.assert(!options.encode || _.isFunction(options.encode)); | ||
node_opcua_assert_1.assert(!options.decode || _.isFunction(options.decode)); | ||
this.encode = options.encode || _encode_enumeration; | ||
@@ -52,4 +52,4 @@ this.decode = options.decode || function _decode_enumeration(stream) { | ||
function registerEnumeration(options) { | ||
node_opcua_assert_1.default(options.hasOwnProperty("name")); | ||
node_opcua_assert_1.default(options.hasOwnProperty("enumValues")); | ||
node_opcua_assert_1.assert(options.hasOwnProperty("name")); | ||
node_opcua_assert_1.assert(options.hasOwnProperty("enumValues")); | ||
const name = options.name; | ||
@@ -69,3 +69,3 @@ if (_enumerations.hasOwnProperty(name)) { | ||
function getEnumeration(enumerationName) { | ||
node_opcua_assert_1.default(exports.hasEnumeration(enumerationName)); | ||
node_opcua_assert_1.assert(exports.hasEnumeration(enumerationName)); | ||
return _enumerations.get(enumerationName); | ||
@@ -72,0 +72,0 @@ } |
@@ -49,3 +49,3 @@ "use strict"; | ||
function callConstructor(constructor) { | ||
node_opcua_assert_1.default(_.isFunction(constructor)); | ||
node_opcua_assert_1.assert(_.isFunction(constructor)); | ||
const constructorFunc = constructor.bind.apply(constructor, arguments); | ||
@@ -52,0 +52,0 @@ return new constructorFunc(); |
@@ -22,5 +22,5 @@ "use strict"; | ||
function check_schema_correctness(schema) { | ||
node_opcua_assert_1.default(typeof schema.name === "string", " expecting schema to have a name"); | ||
node_opcua_assert_1.default(schema.fields instanceof Array, " expecting schema to provide a set of fields " + schema.name); | ||
node_opcua_assert_1.default(schema.baseType === undefined || (typeof schema.baseType === "string")); | ||
node_opcua_assert_1.assert(typeof schema.name === "string", " expecting schema to have a name"); | ||
node_opcua_assert_1.assert(schema.fields instanceof Array, " expecting schema to provide a set of fields " + schema.name); | ||
node_opcua_assert_1.assert(schema.baseType === undefined || (typeof schema.baseType === "string")); | ||
} | ||
@@ -102,4 +102,4 @@ exports.check_schema_correctness = check_schema_correctness; | ||
} | ||
node_opcua_assert_1.default(_.isObject(field)); | ||
node_opcua_assert_1.default(!field.isArray); | ||
node_opcua_assert_1.assert(_.isObject(field)); | ||
node_opcua_assert_1.assert(!field.isArray); | ||
if (field.category === types_1.FieldCategory.complex) { | ||
@@ -133,4 +133,4 @@ if (field.fieldTypeConstructor) { | ||
let i; | ||
node_opcua_assert_1.default(_.isObject(field)); | ||
node_opcua_assert_1.default(field.isArray); | ||
node_opcua_assert_1.assert(_.isObject(field)); | ||
node_opcua_assert_1.assert(field.isArray); | ||
if (!valueArray && field.defaultValue === null) { | ||
@@ -137,0 +137,0 @@ return null; |
@@ -46,3 +46,3 @@ "use strict"; | ||
else if (factories_factories_1.hasStructuredType(fieldType)) { | ||
node_opcua_assert_1.default(fieldType !== "LocalizedText"); // LocalizedText should be treated as BasicType!!! | ||
node_opcua_assert_1.assert(fieldType !== "LocalizedText"); // LocalizedText should be treated as BasicType!!! | ||
return types_1.FieldCategory.complex; | ||
@@ -199,2 +199,3 @@ } | ||
console.log(chalk_1.default.cyan("invalid_options_fields= "), invalidOptionsFields.sort().join(" ")); | ||
console.log("options = ", options); | ||
} | ||
@@ -201,0 +202,0 @@ if (invalidOptionsFields.length !== 0) { |
@@ -28,3 +28,3 @@ "use strict"; | ||
constructor(options) { | ||
node_opcua_assert_1.default(options.category !== null); | ||
node_opcua_assert_1.assert(options.category !== null); | ||
this.encode = options.encode || undefined; | ||
@@ -31,0 +31,0 @@ this.decode = options.decode || undefined; |
{ | ||
"name": "node-opcua-factory", | ||
"version": "2.0.0-alpha.19", | ||
"version": "2.0.0-alpha.21", | ||
"description": "pure nodejs OPCUA SDK - module -factory", | ||
@@ -14,13 +14,13 @@ "main": "./dist/index.js", | ||
"node-opcua-assert": "^2.0.0-alpha.10", | ||
"node-opcua-basic-types": "^2.0.0-alpha.19", | ||
"node-opcua-binary-stream": "^2.0.0-alpha.18", | ||
"node-opcua-enum": "^2.0.0-alpha.18", | ||
"node-opcua-basic-types": "^2.0.0-alpha.21", | ||
"node-opcua-binary-stream": "^2.0.0-alpha.21", | ||
"node-opcua-enum": "^2.0.0-alpha.21", | ||
"node-opcua-guid": "^2.0.0-alpha.18", | ||
"node-opcua-nodeid": "^2.0.0-alpha.19", | ||
"node-opcua-status-code": "^2.0.0-alpha.19", | ||
"node-opcua-utils": "^2.0.0-alpha.19", | ||
"node-opcua-nodeid": "^2.0.0-alpha.21", | ||
"node-opcua-status-code": "^2.0.0-alpha.21", | ||
"node-opcua-utils": "^2.0.0-alpha.21", | ||
"underscore": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-debug": "^2.0.0-alpha.18" | ||
"node-opcua-debug": "^2.0.0-alpha.21" | ||
}, | ||
@@ -42,3 +42,3 @@ "author": "Etienne Rossignon", | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "0343e8c37806056ab5bcfb1c5c083e910c7252cb" | ||
"gitHead": "5cbfb647cd06619685d1968520d0bad368858036" | ||
} |
@@ -6,3 +6,3 @@ /** | ||
import chalk from "chalk"; | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import { BinaryStream, BinaryStreamSizeCalculator, OutputBinaryStream } from "node-opcua-binary-stream"; | ||
@@ -9,0 +9,0 @@ import { hexDump } from "node-opcua-debug"; |
/** | ||
* @module node-opcua-factory | ||
*/ | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import { decodeLocaleId, encodeLocaleId, validateLocaleId } from "node-opcua-basic-types"; | ||
@@ -6,0 +6,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
/** | ||
* @module node-opcua-factory | ||
*/ | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; | ||
@@ -6,0 +6,0 @@ import * as _ from "underscore"; |
/** | ||
* @module node-opcua-factory | ||
*/ | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import { | ||
@@ -6,0 +6,0 @@ |
/** | ||
* @module node-opcua-factory | ||
*/ | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import * as _ from "underscore"; | ||
@@ -6,0 +6,0 @@ |
@@ -9,3 +9,3 @@ /** | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import { checkDebugFlag, make_debugLog } from "node-opcua-debug"; | ||
@@ -12,0 +12,0 @@ import { ExpandedNodeId } from "node-opcua-nodeid"; |
/** | ||
* @module node-opcua-factory | ||
*/ | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import { make_debugLog } from "node-opcua-debug"; | ||
@@ -6,0 +6,0 @@ import * as _ from "underscore"; |
@@ -24,3 +24,3 @@ /** | ||
import { lowerFirstLetter } from "node-opcua-utils"; | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
@@ -251,2 +251,3 @@ // export interface StructuredTypeSchemaInterface extends CommonInterface { | ||
console.log(chalk.cyan("invalid_options_fields= "), invalidOptionsFields.sort().join(" ")); | ||
console.log("options = ", options); | ||
} | ||
@@ -253,0 +254,0 @@ if (invalidOptionsFields.length !== 0) { |
/** | ||
* @module node-opcua-factory | ||
*/ | ||
import assert from "node-opcua-assert"; | ||
import { assert } from "node-opcua-assert"; | ||
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; | ||
@@ -6,0 +6,0 @@ import { Enum, EnumItem } from "node-opcua-enum"; |
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
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
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
177337
3465