<commit_before>#include "node_request.hpp"
#include "node_file_source.hpp"
#include <mbgl/storage/request.hpp>
#include <mbgl/storage/response.hpp>

#include <cmath>

namespace node_mbgl {

////////////////////////////////////////////////////////////////////////////////////////////////
// Static Node Methods

v8::Persistent<v8::FunctionTemplate> NodeRequest::constructorTemplate;

void NodeRequest::Init(v8::Handle<v8::Object> target) {
    NanScope();

    v8::Local<v8::FunctionTemplate> t = NanNew<v8::FunctionTemplate>(New);

    t->InstanceTemplate()->SetInternalFieldCount(1);
    t->SetClassName(NanNew("Request"));

    NODE_SET_PROTOTYPE_METHOD(t, "respond", Respond);

    NanAssignPersistent(constructorTemplate, t);

    target->Set(NanNew("Request"), t->GetFunction());
}

NAN_METHOD(NodeRequest::New) {
    NanScope();

    // Extract the pointer from the first argument
    if (args.Length() < 2 || !NanHasInstance(NodeFileSource::constructorTemplate, args[0]) || !args[1]->IsExternal()) {
        return NanThrowTypeError("Cannot create Request objects explicitly");
    }

    v8::Persistent<v8::Object> source;
    NanAssignPersistent(source, args[0]->ToObject());

    auto request = reinterpret_cast<mbgl::Request *>(args[1].As<v8::External>()->Value());
    auto req = new NodeRequest(NanNew<v8::Object>(std::move(source)), request);
    req->Wrap(args.This());

    NanReturnValue(args.This());
}<commit_msg>drop extraneous NodeFileSource v8::Persistent<commit_after>#include "node_request.hpp"
#include "node_file_source.hpp"
#include <mbgl/storage/request.hpp>
#include <mbgl/storage/response.hpp>

#include <cmath>

namespace node_mbgl {

////////////////////////////////////////////////////////////////////////////////////////////////
// Static Node Methods

v8::Persistent<v8::FunctionTemplate> NodeRequest::constructorTemplate;

void NodeRequest::Init(v8::Handle<v8::Object> target) {
    NanScope();

    v8::Local<v8::FunctionTemplate> t = NanNew<v8::FunctionTemplate>(New);

    t->InstanceTemplate()->SetInternalFieldCount(1);
    t->SetClassName(NanNew("Request"));

    NODE_SET_PROTOTYPE_METHOD(t, "respond", Respond);

    NanAssignPersistent(constructorTemplate, t);

    target->Set(NanNew("Request"), t->GetFunction());
}

NAN_METHOD(NodeRequest::New) {
    NanScope();

    // Extract the pointer from the first argument
    if (args.Length() < 2 || !NanHasInstance(NodeFileSource::constructorTemplate, args[0]) || !args[1]->IsExternal()) {
        return NanThrowTypeError("Cannot create Request objects explicitly");
    }

    auto request = reinterpret_cast<mbgl::Request *>(args[1].As<v8::External>()->Value());
    auto req = new NodeRequest(args[0]->ToObject(), request);
    req->Wrap(args.This());

    NanReturnValue(args.This());
}
{'fraction_non_alphanumeric': 0.2209051724137931, 'fraction_numerical': 0.011494252873563218, 'mean_word_length': 3.7770154373927958, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 41, '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': '2090126', 'n_tokens_mistral': 856, 'n_tokens_neox': 803, 'n_words': 137}