| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ repo.open( path.resolve( '../.git' ), function() { | |||
| 18 | 18 | ||
| 19 | 19 | console.log( entry.name() + ':' ); | |
| 20 | 20 | console.log( blob.rawSize() ); | |
| 21 | - console.log( blob.rawContent() ); | ||
| 21 | + console.log( typeof blob.rawContent() ); | ||
| 22 | 22 | } | |
| 23 | 23 | }); | |
| 24 | 24 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + #ifndef UTILS_H | ||
| 2 | + #define UTILS_H | ||
| 3 | + | ||
| 4 | + #define MAKE_FAST_BUFFER(NG_SLOW_BUFFER, NG_FAST_BUFFER) \ | ||
| 5 | + Local<Function> NG_JS_BUFFER = Local<Function>::Cast( \ | ||
| 6 | + Context::GetCurrent()->Global()->Get( \ | ||
| 7 | + String::New("Buffer"))); \ | ||
| 8 | + \ | ||
| 9 | + Handle<Value> NG_JS_ARGS[3] = { \ | ||
| 10 | + NG_SLOW_BUFFER->handle_, \ | ||
| 11 | + Integer::New(Buffer::Length(NG_SLOW_BUFFER)), \ | ||
| 12 | + Integer::New(0) \ | ||
| 13 | + }; \ | ||
| 14 | + \ | ||
| 15 | + NG_FAST_BUFFER = NG_JS_BUFFER->NewInstance(3, NG_JS_ARGS); | ||
| 16 | + | ||
| 17 | + #endif | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | { | |
| 2 | 2 | "name": "nodegit", | |
| 3 | 3 | "description": "Node.js libgit2 asynchronous native bindings", | |
| 4 | - "version": "0.0.4", | ||
| 4 | + "version": "0.0.5", | ||
| 5 | 5 | "homepage": "https://github.com/tbranyen/nodegit", | |
| 6 | 6 | "author": "Tim Branyen <tim@tabdeveloper.com> (http://twitter.com/tbranyen)", | |
| 7 | 7 | "main": "./lib/index.js", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | 11 | #include "../vendor/libgit2/include/git2.h" | |
| 12 | 12 | ||
| 13 | + #include "../include/utils.h" | ||
| 13 | 14 | #include "../include/repo.h" | |
| 14 | 15 | #include "../include/blob.h" | |
| 15 | 16 | ||
@@ -149,9 +150,13 @@ Handle<Value> GitBlob::RawContent(const Arguments& args) { | |||
| 149 | 150 | int rawSize = blob->RawSize(); | |
| 150 | 151 | const char* contents = (const char *)const_cast<void *>(blob->RawContent()); | |
| 151 | 152 | ||
| 152 | - Buffer* buffer = Buffer::New(const_cast<char *>(contents), strlen(contents)); | ||
| 153 | + int bufferLength = strlen(contents); | ||
| 154 | + Buffer* buffer = Buffer::New(const_cast<char *>(contents), bufferLength); | ||
| 155 | + | ||
| 156 | + Local<Object> fastBuffer; | ||
| 157 | + MAKE_FAST_BUFFER(buffer, fastBuffer); | ||
| 153 | 158 | ||
| 154 | - return scope.Close( buffer->handle_ ); | ||
| 159 | + return scope.Close( fastBuffer ); | ||
| 155 | 160 | } | |
| 156 | 161 | ||
| 157 | 162 | Handle<Value> GitBlob::RawSize(const Arguments& args) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import os, shutil, platform | |||
| 4 | 4 | from os import system | |
| 5 | 5 | from os.path import exists, abspath | |
| 6 | 6 | ||
| 7 | - VERSION = '0.0.4' | ||
| 7 | + VERSION = '0.0.5' | ||
| 8 | 8 | APPNAME = 'nodegit' | |
| 9 | 9 | srcdir = '.' | |
| 10 | 10 | blddir = 'build' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments