node-opcua-utils
Advanced tools
Comparing version 0.5.0 to 2.0.0-alpha.2
@@ -7,7 +7,4 @@ /** | ||
* @method set_flag | ||
* @param value | ||
* @param mask< | ||
* @return {number} | ||
*/ | ||
export declare function set_flag(value: number, mask: { | ||
export declare function set_flag(value: number, mask: number | { | ||
value: number; | ||
@@ -18,8 +15,4 @@ }): number; | ||
* @method check_flag | ||
* | ||
* @param value | ||
* @param mask | ||
* @return {boolean} | ||
*/ | ||
export declare function check_flag(value: number, mask: { | ||
export declare function check_flag(value: number, mask: number | { | ||
value: number; | ||
@@ -30,3 +23,3 @@ }): boolean; | ||
* @param baseFolder | ||
* @param full_path_to_file | ||
* @param fullPathToFile | ||
* | ||
@@ -37,3 +30,3 @@ * | ||
*/ | ||
export declare function normalize_require_file(baseFolder: string, full_path_to_file: string): string; | ||
export declare function normalize_require_file(baseFolder: string, fullPathToFile: string): string; | ||
export declare function isNullOrUndefined(value: any): boolean; | ||
@@ -40,0 +33,0 @@ export { buffer_ellipsis } from "./buffer_ellipsis"; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const assert = require("node-opcua-assert").assert; | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
const path = require("path"); | ||
@@ -12,9 +12,9 @@ /** | ||
* @method set_flag | ||
* @param value | ||
* @param mask< | ||
* @return {number} | ||
*/ | ||
function set_flag(value, mask) { | ||
assert(mask !== undefined); | ||
return value | mask.value; | ||
if (mask.value) | ||
mask = mask.value; | ||
node_opcua_assert_1.assert(!mask.hasOwnProperty("value")); | ||
node_opcua_assert_1.assert(mask !== undefined); | ||
return value | mask; | ||
} | ||
@@ -25,10 +25,8 @@ exports.set_flag = set_flag; | ||
* @method check_flag | ||
* | ||
* @param value | ||
* @param mask | ||
* @return {boolean} | ||
*/ | ||
function check_flag(value, mask) { | ||
assert(mask !== undefined && mask.value); | ||
return (value & mask.value) === mask.value; | ||
if (mask.value) | ||
mask = mask.value; | ||
node_opcua_assert_1.assert(!mask.hasOwnProperty("value")); | ||
return ((value & mask) === mask); | ||
} | ||
@@ -40,3 +38,3 @@ exports.check_flag = check_flag; | ||
* @param baseFolder | ||
* @param full_path_to_file | ||
* @param fullPathToFile | ||
* | ||
@@ -47,11 +45,11 @@ * | ||
*/ | ||
function normalize_require_file(baseFolder, full_path_to_file) { | ||
let local_file = path.relative(baseFolder, full_path_to_file).replace(/\\/g, "/"); | ||
function normalize_require_file(baseFolder, fullPathToFile) { | ||
let localFile = path.relative(baseFolder, fullPathToFile).replace(/\\/g, "/"); | ||
// append ./ if necessary | ||
if (local_file.substr(0, 1) !== ".") { | ||
local_file = "./" + local_file; | ||
if (localFile.substr(0, 1) !== ".") { | ||
localFile = "./" + localFile; | ||
} | ||
// remove extension | ||
local_file = local_file.substr(0, local_file.length - path.extname(local_file).length); | ||
return local_file; | ||
localFile = localFile.substr(0, localFile.length - path.extname(localFile).length); | ||
return localFile; | ||
} | ||
@@ -58,0 +56,0 @@ exports.normalize_require_file = normalize_require_file; |
export declare class LineFile { | ||
__line: string[]; | ||
private _line; | ||
constructor(); | ||
@@ -7,2 +7,3 @@ write(...arg: string[]): void; | ||
save(filename: string): void; | ||
saveFormat(filename: string, formatter: (code: string) => string): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs_1 = require("fs"); | ||
const os = require("os"); | ||
class LineFile { | ||
constructor() { | ||
this.__line = []; | ||
this._line = []; | ||
this.write("// --------- This code has been automatically generated !!! " + new Date().toISOString()); | ||
@@ -14,6 +15,6 @@ } | ||
} | ||
this.__line.push(str); | ||
this._line.push(str); | ||
} | ||
toString() { | ||
return this.__line.join("\n"); | ||
return this._line.join(os.EOL); | ||
} | ||
@@ -23,4 +24,8 @@ save(filename) { | ||
} | ||
saveFormat(filename, formatter) { | ||
const code = formatter(this.toString()); | ||
fs_1.writeFileSync(filename, code, "ascii"); | ||
} | ||
} | ||
exports.LineFile = LineFile; | ||
//# sourceMappingURL=linefile.js.map |
@@ -1,1 +0,1 @@ | ||
export declare function setDeprecated(Constructor: Function, methodName: string, helpString: string): void; | ||
export declare function setDeprecated(constructor: Function, methodName: string, helpString: string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const assert = require("node-opcua-assert").assert; | ||
const chalk = require("chalk"); | ||
function setDeprecated(Constructor, methodName, helpString) { | ||
const old_method = Constructor.prototype[methodName]; | ||
assert(old_method instanceof Function, "expecting a valid " + methodName + "method on class ", Constructor.constructor.name); | ||
// tslint:disable:ban-types | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
const chalk_1 = require("chalk"); | ||
function setDeprecated(constructor, methodName, helpString) { | ||
const oldMethod = constructor.prototype[methodName]; | ||
node_opcua_assert_1.assert(oldMethod instanceof Function, "expecting a valid " + methodName + "method on class " + constructor.constructor.name); | ||
let counter = 0; | ||
Constructor.prototype[methodName] = function () { | ||
constructor.prototype[methodName] = function () { | ||
if (counter % 1000 === 0) { | ||
console.log(chalk.green("Warning !"), "", chalk.green(chalk.bold(Constructor.name + "#" + methodName), " is now deprecated")); | ||
console.log(chalk_1.default.green("Warning !"), "", chalk_1.default.green(chalk_1.default.bold(constructor.name + "#" + methodName), " is now deprecated")); | ||
console.log(" ", helpString); | ||
} | ||
counter++; | ||
return old_method.apply(this, arguments); | ||
return oldMethod.apply(this, arguments); | ||
}; | ||
@@ -17,0 +18,0 @@ } |
{ | ||
"name": "node-opcua-utils", | ||
"version": "0.5.0", | ||
"version": "2.0.0-alpha.2", | ||
"description": "pure nodejs OPCUA SDK - module -utils", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "mocha test" | ||
"test": "mocha test", | ||
"clean": "node -e \"require('rimraf').sync('dist');\"" | ||
}, | ||
"dependencies": { | ||
"node-opcua-assert": "^0.5.0", | ||
"node-opcua-assert": "^2.0.0-alpha.2", | ||
"underscore": "^1.9.1" | ||
@@ -20,3 +21,3 @@ }, | ||
"should": "13.2.3", | ||
"sinon": "^7.1.0" | ||
"sinon": "^7.0.0" | ||
}, | ||
@@ -38,3 +39,3 @@ "author": "Etienne Rossignon", | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "7c2f2dcb6ebdc49e57da1a028406a307df502d4e" | ||
"gitHead": "7f57dd90e9d8bd1abcb8d330b3470999ac51e33f" | ||
} |
@@ -5,3 +5,3 @@ /** | ||
const assert = require("node-opcua-assert").assert; | ||
import { assert } from "node-opcua-assert"; | ||
const path = require("path"); | ||
@@ -12,9 +12,8 @@ | ||
* @method set_flag | ||
* @param value | ||
* @param mask< | ||
* @return {number} | ||
*/ | ||
export function set_flag(value: number, mask: { value: number }): number { | ||
export function set_flag(value: number, mask: number| {value: number}): number { | ||
if ((mask as any).value) mask = (mask as any).value; | ||
assert(!mask.hasOwnProperty("value")); | ||
assert(mask !== undefined); | ||
return value | mask.value; | ||
return value | (mask as number); | ||
} | ||
@@ -24,10 +23,7 @@ /** | ||
* @method check_flag | ||
* | ||
* @param value | ||
* @param mask | ||
* @return {boolean} | ||
*/ | ||
export function check_flag(value: number, mask: { value: number }): boolean { | ||
assert(mask !== undefined && mask.value); | ||
return (value & mask.value) === mask.value; | ||
export function check_flag(value: number, mask: number| {value: number}): boolean { | ||
if ((mask as any).value) mask = (mask as any).value; | ||
assert(!mask.hasOwnProperty("value")); | ||
return ((value & (mask as number)) === (mask as number)); | ||
} | ||
@@ -39,3 +35,3 @@ | ||
* @param baseFolder | ||
* @param full_path_to_file | ||
* @param fullPathToFile | ||
* | ||
@@ -46,11 +42,11 @@ * | ||
*/ | ||
export function normalize_require_file(baseFolder: string, full_path_to_file: string): string { | ||
let local_file = path.relative(baseFolder, full_path_to_file).replace(/\\/g, "/"); | ||
export function normalize_require_file(baseFolder: string, fullPathToFile: string): string { | ||
let localFile = path.relative(baseFolder, fullPathToFile).replace(/\\/g, "/"); | ||
// append ./ if necessary | ||
if (local_file.substr(0, 1) !== ".") { | ||
local_file = "./" + local_file; | ||
if (localFile.substr(0, 1) !== ".") { | ||
localFile = "./" + localFile; | ||
} | ||
// remove extension | ||
local_file = local_file.substr(0, local_file.length - path.extname(local_file).length); | ||
return local_file; | ||
localFile = localFile.substr(0, localFile.length - path.extname(localFile).length); | ||
return localFile; | ||
} | ||
@@ -57,0 +53,0 @@ |
import { writeFileSync } from "fs"; | ||
import * as os from "os"; | ||
export class LineFile { | ||
__line: string[]; | ||
private _line: string[]; | ||
constructor() { | ||
this.__line = []; | ||
this._line = []; | ||
this.write("// --------- This code has been automatically generated !!! " + new Date().toISOString()); | ||
@@ -16,7 +18,7 @@ } | ||
} | ||
this.__line.push(str); | ||
this._line.push(str); | ||
} | ||
toString(): string { | ||
return this.__line.join("\n"); | ||
return this._line.join(os.EOL); | ||
} | ||
@@ -27,2 +29,7 @@ | ||
} | ||
saveFormat(filename: string, formatter: (code: string) => string): void { | ||
const code = formatter(this.toString()); | ||
writeFileSync(filename, code, "ascii"); | ||
} | ||
} |
@@ -6,4 +6,4 @@ /** | ||
*/ | ||
export function getObjectClassName(obj: object):string { | ||
export function getObjectClassName(obj: object): string { | ||
return Object.prototype.toString.call(obj).slice(8, -1); | ||
} |
@@ -1,19 +0,20 @@ | ||
const assert = require("node-opcua-assert").assert; | ||
const chalk = require("chalk"); | ||
export function setDeprecated(Constructor: Function,methodName: string ,helpString: string):void | ||
{ | ||
const old_method= Constructor.prototype[methodName]; | ||
assert(old_method instanceof Function,"expecting a valid " + methodName + "method on class ", Constructor.constructor.name); | ||
// tslint:disable:ban-types | ||
import { assert } from "node-opcua-assert"; | ||
import chalk from "chalk"; | ||
export function setDeprecated(constructor: Function, methodName: string, helpString: string): void { | ||
const oldMethod = constructor.prototype[methodName]; | ||
assert(oldMethod instanceof Function, "expecting a valid " + methodName + "method on class " + constructor.constructor.name); | ||
let counter = 0; | ||
Constructor.prototype[methodName] = function() { | ||
if (counter % 1000 === 0 ) { | ||
console.log(chalk.green("Warning !"),"", chalk.green(chalk.bold(Constructor.name+"#"+methodName)," is now deprecated")); | ||
constructor.prototype[methodName] = function () { | ||
if (counter % 1000 === 0) { | ||
console.log(chalk.green("Warning !"), "", chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated")); | ||
console.log(" ", helpString); | ||
} | ||
counter ++; | ||
return old_method.apply(this,arguments); | ||
} | ||
counter++; | ||
return oldMethod.apply(this, arguments); | ||
}; | ||
} |
{ | ||
"extends" : "../tsconfig.json", | ||
"compilerOptions": { | ||
"skipLibCheck": true, | ||
"target": "es6", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"outDir": "./dist", | ||
"sourceMap": true, | ||
"sourceRoot": "./source", | ||
"strict": true | ||
"rootDir": "source", | ||
"outDir": "dist" | ||
} | ||
} |
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
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
55217
1028
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addednode-opcua-assert@2.120.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedbetter-assert@1.0.2(transitive)
- Removedcallsite@1.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removednode-opcua-assert@0.5.0(transitive)
- Removedsupports-color@5.5.0(transitive)