How to use the node-opcua-utils.capitalizeFirstLetter function in node-opcua-utils

To help you get started, we’ve selected a few node-opcua-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-generator / source / factory_code_generator.ts View on Github external
function write_enumeration(
  write: WriteFunc,
  schema: StructuredTypeSchema,
  field: FieldType,
  member: string,
  i: number
): void {
    assert(!field.isArray); // would not work in this case
    const capMember = capitalizeFirstLetter(member);
    write(
      `        this.${field.name} = this.set${capMember}(initialize_field(schema.fields[${i}], options.${field.name}));`
    );
}
github node-opcua / node-opcua / packages / node-opcua-generator / source / factory_code_generator.ts View on Github external
function write_enumeration_setter(
  write: WriteFunc,
  schema: StructuredTypeSchema,
  field: FieldType, member: string
): void {
    const capMember = capitalizeFirstLetter(member);
    write(`    public set${capMember}(value: any): ${field.fieldType} {`);
    write(`        const coercedValue = _enumeration${field.fieldType}.get(value);`);
    write(`        /* istanbul ignore next */`);
    write(`        if (coercedValue === undefined || coercedValue === null) {`);
    write(`           throw new Error("value cannot be coerced to ${field.fieldType} :" + value);`);
    write(`        }`);
    write(`        this.${member} = coercedValue.value as ${field.fieldType};`);
    write(`        return this.${member};`);
    write(`    }`);
}
github node-opcua / node-opcua / packages / node-opcua-generator / src / factory_code_generator.js View on Github external
function write_enumeration(f, schema, field, member, i) {
    assert(f instanceof LineFile);
    function write() {
        f.write.apply(f, arguments);
    }

    //xx const __member = "$" + member;

    assert(!field.isArray); // would not work in this case

    const capMember = utils.capitalizeFirstLetter(member);
    write(
        "    self.set" + capMember + "(initialize_field(schema.fields[" + i + "]" + ", options." + field.name + "));"
    );
}
github node-opcua / node-opcua / packages / node-opcua-generator / src / factory_code_generator.js View on Github external
function write_enumeration_setter(f, schema, field, member, i) {
    assert(f instanceof LineFile);
    function write() {
        f.write.apply(f, arguments);
    }
    const className = schema.name;
    const capMember = utils.capitalizeFirstLetter(member);
    write(className + ".prototype.set" + capMember + " = function(value) {");
    write("   const coercedValue = _enumerations." + field.fieldType + ".typedEnum.get(value);");
    write("   /* istanbul ignore next */");
    write("   if (coercedValue === undefined || coercedValue === null) {");
    write('      throw new Error("value cannot be coerced to ' + field.fieldType + ': " + value);');
    write("   }");
    write("   this." + member + " = coercedValue;");
    write("};");
}
function write_enumeration(f, schema, field, member, i) {
github node-opcua / node-opcua / packages / node-opcua-address-space / src / nodeset_to_xml.ts View on Github external
function _dumpVariantExtensionObjectValue_Body(
    xw: XmlWriter,
    schema: any,
    value: any
) {

    xw.startElement(schema.name);
    if (value) {
        for (const field of schema.fields) {
            xw.startElement(utils.capitalizeFirstLetter(field.name));
            const v = value[field.name];
            if (v !== null && v !== undefined) {
                switch (field.fieldType) {
                    case "UInt64":
                    case "Int64":
                        xw.text(v[1].toString());
                        break;
                    case "LocalizedText":
                        xw.startElement("Locale");
                        if (v.locale) {
                            xw.text(v.locale);
                        }
                        xw.endElement();
                        xw.startElement("Text");
                        if (v.text) {
                            xw.text(v.text);