<commit_before>#include "nan.h"
using namespace v8;

#include "keytar.h"

namespace {

NAN_METHOD(AddPassword) {
  NanScope();
  bool success = keytar::AddPassword(*String::Utf8Value(args[0]),
                                     *String::Utf8Value(args[1]),
                                     *String::Utf8Value(args[2]));
  NanReturnValue(NanNew<Boolean>(success));
}

NAN_METHOD(GetPassword) {
  NanScope();
  std::string password;
  bool success = keytar::GetPassword(*String::Utf8Value(args[0]),
                                     *String::Utf8Value(args[1]),
                                     &password);
  if (success)
    NanReturnValue(NanNew<String>(password.data(), password.length()));
  else
    NanReturnNull();
}

NAN_METHOD(DeletePassword) {
  NanScope();
  bool success = keytar::DeletePassword(*String::Utf8Value(args[0]),
                                        *String::Utf8Value(args[1]));
  NanReturnValue(NanNew<Boolean>(success));
}

NAN_METHOD(FindPassword) {
  NanScope();
  std::string password;
  bool success = keytar::FindPassword(*String::Utf8Value(args[0]), &password);
  if (success)
    NanReturnValue(NanNew<String>(password.data(), password.length()));
  else
    NanReturnNull();
}

void Init(Handle<Object> exports) {
  NODE_SET_METHOD(exports, "getPassword", GetPassword);
  NODE_SET_METHOD(exports, "addPassword", AddPassword);
  NODE_SET_METHOD(exports, "deletePassword", DeletePassword);
  NODE_SET_METHOD(exports, "findPassword", FindPassword);
}

}  // namespace<commit_msg>Update to Nan 2.0 Syntax<commit_after>#include "nan.h"
using namespace v8;

#include "keytar.h"

namespace {

NAN_METHOD(AddPassword) {
  Nan::HandleScope scope;
  bool success = keytar::AddPassword(*String::Utf8Value(info[0]),
                                     *String::Utf8Value(info[1]),
                                     *String::Utf8Value(info[2]));
  info.GetReturnValue().Set(Nan::New<Boolean>(success));
}

NAN_METHOD(GetPassword) {
  Nan::HandleScope scope;
  std::string password;
  bool success = keytar::GetPassword(*String::Utf8Value(info[0]),
                                     *String::Utf8Value(info[1]),
                                     &password);
  if (success)
    info.GetReturnValue().Set(Nan::New<String>(password.data(), password.length())).ToLocalChecked();
  else
    info.GetReturnValue().Set(Nan::Null());
}

NAN_METHOD(DeletePassword) {
  Nan::HandleScope scope;
  bool success = keytar::DeletePassword(*String::Utf8Value(info[0]),
                                        *String::Utf8Value(info[1]));
  info.GetReturnValue().Set(Nan::New<Boolean>(success));
}

NAN_METHOD(FindPassword) {
  Nan::HandleScope scope;
  std::string password;
  bool success = keytar::FindPassword(*String::Utf8Value(info[0]), &password);
  if (success)
    info.GetReturnValue().Set(Nan::New<String>(password.data(), password.length())).ToLocalChecked();
  else
    info.GetReturnValue().Set(Nan::Null());
}

void Init(Handle<Object> exports) {
  Nan::SetMethod(exports, "getPassword", GetPassword);
  Nan::SetMethod(exports, "addPassword", AddPassword);
  Nan::SetMethod(exports, "deletePassword", DeletePassword);
  Nan::SetMethod(exports, "findPassword", FindPassword);
}

}  // namespace
{'fraction_non_alphanumeric': 0.15539079394501082, 'fraction_numerical': 0.011121408711770158, 'mean_word_length': 3.5350140056022408, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4684857', 'n_tokens_mistral': 1020, 'n_tokens_neox': 987, 'n_words': 143}