<commit_before>#include <nan.h>

#include <LzmaLib.h>

using namespace std;
using namespace v8;
using namespace node;

NAN_METHOD(compress) {
    NanScope();

    size_t len = Buffer::Length(args[0]);
    const char *in = Buffer::Data(args[0]);

    unsigned char props[LZMA_PROPS_SIZE];
    size_t propsSize = LZMA_PROPS_SIZE;

    size_t outLen = len + 128 + len / 3;
    char* out = new char[outLen];
    int res = LzmaCompress((unsigned char*)out + propsSize, &outLen, (unsigned char*)in, len, props, &propsSize, 5, (1 << 24), 3, 0, 2, 32, 2);

    Local<Object> ret = NanNewBufferHandle(outLen);
    char *retBuf = Buffer::Data(ret);
    memcpy(retBuf, out, outLen);
    NanReturnValue(ret);
}

NAN_METHOD(decompress) {
    NanScope();

    Local<Object> ret;
    NanReturnValue(ret);
}

void init(v8::Handle<v8::Object> exports) {
    NODE_SET_METHOD(exports, "compress", compress);
    NODE_SET_METHOD(exports, "decompress", decompress);
}

NODE_MODULE(lzma, init);<commit_msg>compress.<commit_after>#include <nan.h>

#include <LzmaLib.h>

using namespace std;
using namespace v8;
using namespace node;

NAN_METHOD(compress) {
    NanScope();

    if (args.Length() == 0) {
        NanReturnUndefined();
    }

    int level = 5;
    int threads = 1;

    if (args[1]->IsNumber()) {
        int argLvl = args[1]->Int32Value();
        if (argLvl >= 0 && argLvl <= 9) level = argLvl;
    }

    if (args[2]->IsNumber()) {
        int argTh = args[2]->Int32Value();
        if (argTh == 1 || argTh == 2) level = argTh;
    }

    size_t len = Buffer::Length(args[0]);
    const char *in = Buffer::Data(args[0]);

    unsigned char props[LZMA_PROPS_SIZE];
    size_t propsSize = LZMA_PROPS_SIZE;

    size_t outLen = len + 128 + len / 3;
    char* out = new char[outLen];
    int res = LzmaCompress((unsigned char*)out + propsSize, &outLen, (unsigned char*)in, len, props, &propsSize, level, 0, -1, -1, -1, -1, threads);

    Local<Object> ret = NanNewBufferHandle(outLen);
    char *retBuf = Buffer::Data(ret);
    memcpy(retBuf, out, outLen);

    delete out;
    NanReturnValue(ret);
}

NAN_METHOD(decompress) {
    NanScope();

    Local<Object> ret;
    NanReturnValue(ret);
}

void init(v8::Handle<v8::Object> exports) {
    NODE_SET_METHOD(exports, "compress", compress);
    NODE_SET_METHOD(exports, "decompress", decompress);
}

NODE_MODULE(lzma, init);
{'fraction_non_alphanumeric': 0.1530008453085376, 'fraction_numerical': 0.02028740490278952, 'mean_word_length': 3.6320939334637963, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4574120', 'n_tokens_mistral': 904, 'n_tokens_neox': 846, 'n_words': 200}