Returns the operating system's default directory for temp files.
+## os.endianness()
+
+Returns the endianness of the CPU. Possible values are `"BE"` or `"LE"`.
+
## os.hostname()
Returns the hostname of the operating system.
var binding = process.binding('os');
var util = require('util');
+exports.endianness = binding.getEndianness;
exports.hostname = binding.getHostname;
exports.loadavg = binding.getLoadAvg;
exports.uptime = binding.getUptime;
using namespace v8;
+static Handle<Value> GetEndianness(const Arguments& args) {
+ HandleScope scope;
+ int i = 1;
+ bool big = (*(char *)&i) == 0;
+ Local<String> endianness = String::New(big ? "BE" : "LE");
+ return scope.Close(endianness);
+}
+
static Handle<Value> GetHostname(const Arguments& args) {
HandleScope scope;
char s[255];
void OS::Initialize(v8::Handle<v8::Object> target) {
HandleScope scope;
+ NODE_SET_METHOD(target, "getEndianness", GetEndianness);
NODE_SET_METHOD(target, "getHostname", GetHostname);
NODE_SET_METHOD(target, "getLoadAvg", GetLoadAvg);
NODE_SET_METHOD(target, "getUptime", GetUptime);
process.env.TEMP = '';
assert.equal(os.tmpDir(), t);
+var endianness = os.endianness();
+console.log('endianness = %s', endianness);
+assert.ok(/[BL]E/.test(endianness));
+
var hostname = os.hostname();
console.log('hostname = %s', hostname);
assert.ok(hostname.length > 0);