<commit_before>#include <node.h>
#include <v8.h>

extern "C" {

#include <occoaphelper.h>

}

using namespace v8;

void bind_hello( const FunctionCallbackInfo<Value>& args ) {
	Isolate* isolate = Isolate::GetCurrent();

	args.GetReturnValue().Set( String::NewFromUtf8( isolate, "world" ) );
}

void bind_CoAPToOCResponseCode( const FunctionCallbackInfo<Value>& args ) {
	Isolate* isolate = Isolate::GetCurrent();

	if ( args.Length() < 1 ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "Need coapCode" ) ) );
		return;
	}

	if ( !args[ 0 ]->IsNumber() ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "coapCode must be a number" ) ) );
		return;
	}

	args.GetReturnValue().Set(
		Number::New( isolate,
			( double )CoAPToOCResponseCode( ( uint8_t )args[ 0 ]->Uint32Value() ) ) );
}

void InitFunctions( Handle<Object> exports ) {
	NODE_SET_METHOD( exports, "hello", bind_hello );
	NODE_SET_METHOD( exports, "CoAPToOCResponseCode", bind_CoAPToOCResponseCode );
}
<commit_msg>CreateNewOptionNode: Start binding<commit_after>#include <node.h>
#include <v8.h>

extern "C" {

#include <occoaphelper.h>

}

using namespace v8;

void bind_hello( const FunctionCallbackInfo<Value>& args ) {
	Isolate* isolate = Isolate::GetCurrent();

	args.GetReturnValue().Set( String::NewFromUtf8( isolate, "world" ) );
}

void bind_CoAPToOCResponseCode( const FunctionCallbackInfo<Value>& args ) {
	Isolate* isolate = Isolate::GetCurrent();

	if ( args.Length() < 1 ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "Need coapCode" ) ) );
		return;
	}

	if ( !args[ 0 ]->IsNumber() ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "coapCode must be a number" ) ) );
		return;
	}

	args.GetReturnValue().Set(
		Number::New( isolate,
			( double )CoAPToOCResponseCode( ( uint8_t )args[ 0 ]->Uint32Value() ) ) );
}

void bind_CreateNewOptionNode( const FunctionCallbackInfo<Value>& args ) {
	Isolate* isolate = Isolate::GetCurrent();

	if ( args.Length() < 3 ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "Need key, length, and data" ) ) );
		return;
	}

	if ( !args[ 0 ]->IsNumber() ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "key must be a number" ) ) );
		return;
	}

	if ( !args[ 1 ]->IsNumber() ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "length must be a number" ) ) );
		return;
	}

	if ( !args[ 2 ]->IsArray() ) {
		isolate->ThrowException( Exception::TypeError(
			String::NewFromUtf8( isolate, "key must be an array" ) ) );
		return;
	}

	args.GetReturnValue().Set(
		Buffer::New( isolate,
			CreateNewOptionNode(
				( unsigned short )args[ 0 ]->ToUint32(),
				( unsigned int )args[ 1 ]->ToUint32(),
				Buffer::Data( args[ 2 ]->ToObject() ) ),
			length ) );
}

void InitFunctions( Handle<Object> exports ) {
	NODE_SET_METHOD( exports, "hello", bind_hello );
	NODE_SET_METHOD( exports, "CoAPToOCResponseCode", bind_CoAPToOCResponseCode );
	NODE_SET_METHOD( exports, "CreateNewOptionNode", bind_CreateNewOptionNode );
}

{'fraction_non_alphanumeric': 0.1552482715273413, 'fraction_numerical': 0.011627906976744186, 'mean_word_length': 4.927374301675978, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 34, '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': '5950990', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1115, 'n_words': 240}