<commit_before>#include "zyre.h"
#include "nan.h"

using namespace v8;
using namespace Nan;

class Zyre: public Nan::ObjectWrap {
    public:
        static NAN_MODULE_INIT (Init) {
            Nan::HandleScope scope;

            // Prepare constructor template
            Local <FunctionTemplate> tpl = Nan::New <FunctionTemplate> (New);
            tpl->SetClassName (Nan::New ("Zyre").ToLocalChecked ());
            tpl->InstanceTemplate ()->SetInternalFieldCount (1);

            // Prototypes
            Nan::SetPrototypeMethod (tpl, "destroy", destroy);
            Nan::SetPrototypeMethod (tpl, "defined", defined);
            Nan::SetPrototypeMethod (tpl, "uuid", uuid);
            Nan::SetPrototypeMethod (tpl, "name", name);
            Nan::SetPrototypeMethod (tpl, "start", start);
            Nan::SetPrototypeMethod (tpl, "stop", stop);
            Nan::SetPrototypeMethod (tpl, "setHeader", set_header);
            Nan::SetPrototypeMethod (tpl, "setVerbose", set_verbose);
            Nan::SetPrototypeMethod (tpl, "join", join);
            Nan::SetPrototypeMethod (tpl, "leave", leave);
            Nan::SetPrototypeMethod (tpl, "print", print);
            Nan::SetPrototypeMethod (tpl, "whisper", whisper);
            Nan::SetPrototypeMethod (tpl, "shout", shout);
            Nan::SetPrototypeMethod (tpl, "recv", recv);

            constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ());
            Nan::Set (target, Nan::New ("Zyre").ToLocalChecked (),
            Nan::GetFunction (tpl).ToLocalChecked ());
        }
    private:
        explicit Zyre (char *name = NULL) {
            self = zyre_new (name);
        }
        ~Zyre () {
        }

    static NAN_METHOD (New) {
        assert (info.IsConstructCall ());
        Zyre *zyre;
        if (info [0]->IsString ()) {
            Nan::Utf8String name (info [0].As<String>());
            zyre = new Zyre (*name);
        }
        else
            zyre = new Zyre ();

        if (zyre) {
            zyre->Wrap (info.This ());
            info.GetReturnValue ().Set (info.This ());
        }
    }

    static NAN_METHOD (destroy) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_destroy (&zyre->self);
    }

    static NAN_METHOD (defined) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        info.GetReturnValue ().Set (Nan::New (zyre->self != NULL));
    }

    static NAN_METHOD (uuid) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        info.GetReturnValue ().Set (Nan::New (zyre_uuid (zyre->self)).ToLocalChecked ());
    }

    static NAN_METHOD (name) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        info.GetReturnValue ().Set (Nan::New (zyre_name (zyre->self)).ToLocalChecked ());
    }

    static NAN_METHOD (start) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_start (zyre->self);
    }

    static NAN_METHOD (stop) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_stop (zyre->self);
    }

    static NAN_METHOD (set_verbose) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_set_verbose (zyre->self);
    }

    static NAN_METHOD (set_header) {
        if (info [0]->IsString ()
        &&  info [1]->IsString ()) {
            Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
            Nan::Utf8String name (info [0].As<String>());
            Nan::Utf8String value (info [0].As<String>());
            zyre_set_header (zyre->self, *name, "%s", *value);
        }
        else
            return Nan::ThrowTypeError (".set_header() expects name and value as strings");
    }

    static NAN_METHOD (join) {
        if (info [0]->IsString ()) {
            Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
            Nan::Utf8String group (info [0].As<String>());
            zyre_join (zyre->self, *group);
        }
        else
            return Nan::ThrowTypeError (".join() expects group as string");
    }
<commit_msg>Problem: setHeader doesn't set the correct value<commit_after>#include "zyre.h"
#include "nan.h"

using namespace v8;
using namespace Nan;

class Zyre: public Nan::ObjectWrap {
    public:
        static NAN_MODULE_INIT (Init) {
            Nan::HandleScope scope;

            // Prepare constructor template
            Local <FunctionTemplate> tpl = Nan::New <FunctionTemplate> (New);
            tpl->SetClassName (Nan::New ("Zyre").ToLocalChecked ());
            tpl->InstanceTemplate ()->SetInternalFieldCount (1);

            // Prototypes
            Nan::SetPrototypeMethod (tpl, "destroy", destroy);
            Nan::SetPrototypeMethod (tpl, "defined", defined);
            Nan::SetPrototypeMethod (tpl, "uuid", uuid);
            Nan::SetPrototypeMethod (tpl, "name", name);
            Nan::SetPrototypeMethod (tpl, "start", start);
            Nan::SetPrototypeMethod (tpl, "stop", stop);
            Nan::SetPrototypeMethod (tpl, "setHeader", set_header);
            Nan::SetPrototypeMethod (tpl, "setVerbose", set_verbose);
            Nan::SetPrototypeMethod (tpl, "join", join);
            Nan::SetPrototypeMethod (tpl, "leave", leave);
            Nan::SetPrototypeMethod (tpl, "print", print);
            Nan::SetPrototypeMethod (tpl, "whisper", whisper);
            Nan::SetPrototypeMethod (tpl, "shout", shout);
            Nan::SetPrototypeMethod (tpl, "recv", recv);

            constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ());
            Nan::Set (target, Nan::New ("Zyre").ToLocalChecked (),
            Nan::GetFunction (tpl).ToLocalChecked ());
        }
    private:
        explicit Zyre (char *name = NULL) {
            self = zyre_new (name);
        }
        ~Zyre () {
        }

    static NAN_METHOD (New) {
        assert (info.IsConstructCall ());
        Zyre *zyre;
        if (info [0]->IsString ()) {
            Nan::Utf8String name (info [0].As<String>());
            zyre = new Zyre (*name);
        }
        else
            zyre = new Zyre ();

        if (zyre) {
            zyre->Wrap (info.This ());
            info.GetReturnValue ().Set (info.This ());
        }
    }

    static NAN_METHOD (destroy) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_destroy (&zyre->self);
    }

    static NAN_METHOD (defined) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        info.GetReturnValue ().Set (Nan::New (zyre->self != NULL));
    }

    static NAN_METHOD (uuid) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        info.GetReturnValue ().Set (Nan::New (zyre_uuid (zyre->self)).ToLocalChecked ());
    }

    static NAN_METHOD (name) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        info.GetReturnValue ().Set (Nan::New (zyre_name (zyre->self)).ToLocalChecked ());
    }

    static NAN_METHOD (start) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_start (zyre->self);
    }

    static NAN_METHOD (stop) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_stop (zyre->self);
    }

    static NAN_METHOD (set_verbose) {
        Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
        zyre_set_verbose (zyre->self);
    }

    static NAN_METHOD (set_header) {
        if (info [0]->IsString ()
        &&  info [1]->IsString ()) {
            Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
            Nan::Utf8String name (info [0].As<String>());
            Nan::Utf8String value (info [1].As<String>());
            zyre_set_header (zyre->self, *name, "%s", *value);
        }
        else
            return Nan::ThrowTypeError (".set_header() expects name and value as strings");
    }

    static NAN_METHOD (join) {
        if (info [0]->IsString ()) {
            Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
            Nan::Utf8String group (info [0].As<String>());
            zyre_join (zyre->self, *group);
        }
        else
            return Nan::ThrowTypeError (".join() expects group as string");
    }

{'fraction_non_alphanumeric': 0.1561022906314386, 'fraction_numerical': 0.0033935280572051875, 'mean_word_length': 2.296843787455054, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2456826', 'n_tokens_mistral': 2716, 'n_tokens_neox': 2635, 'n_words': 570}