| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -443,6 +443,22 @@ On POSIX systems, the operating system release is determined by calling | |||
| 443 | 443 | available, `GetVersionExW()` will be used. See | |
| 444 | 444 | <https://en.wikipedia.org/wiki/Uname#Examples> for more information. | |
| 445 | 445 | ||
| 446 | + ## `os.machine()` | ||
| 447 | + | ||
| 448 | + <!-- YAML | ||
| 449 | + added: REPLACEME | ||
| 450 | + --> | ||
| 451 | + | ||
| 452 | + * Returns {string} | ||
| 453 | + | ||
| 454 | + Returns the machine type as a string, such as `arm`, `aarch64`, `mips`, | ||
| 455 | + `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`. | ||
| 456 | + | ||
| 457 | + On POSIX systems, the machine type is determined by calling | ||
| 458 | + [`uname(3)`][]. On Windows, `RtlGetVersion()` is used, and if it is not | ||
| 459 | + available, `GetVersionExW()` will be used. See | ||
| 460 | + <https://en.wikipedia.org/wiki/Uname#Examples> for more information. | ||
| 461 | + | ||
| 446 | 462 | ## OS constants | |
| 447 | 463 | ||
| 448 | 464 | The following constants are exported by `os.constants`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,7 @@ const { | |||
| 75 | 75 | 0: type, | |
| 76 | 76 | 1: version, | |
| 77 | 77 | 2: release, | |
| 78 | + 3: machine, | ||
| 78 | 79 | } = _getOSInformation(); | |
| 79 | 80 | ||
| 80 | 81 | const getHomeDirectory = getCheckedFunction(_getHomeDirectory); | |
@@ -94,12 +95,17 @@ const getOSType = () => type; | |||
| 94 | 95 | * @returns {string} | |
| 95 | 96 | */ | |
| 96 | 97 | const getOSVersion = () => version; | |
| 98 | + /** | ||
| 99 | + * @returns {string} | ||
| 100 | + */ | ||
| 101 | + const getMachine = () => machine; | ||
| 97 | 102 | ||
| 98 | 103 | getFreeMem[SymbolToPrimitive] = () => getFreeMem(); | |
| 99 | 104 | getHostname[SymbolToPrimitive] = () => getHostname(); | |
| 100 | 105 | getOSVersion[SymbolToPrimitive] = () => getOSVersion(); | |
| 101 | 106 | getOSType[SymbolToPrimitive] = () => getOSType(); | |
| 102 | 107 | getOSRelease[SymbolToPrimitive] = () => getOSRelease(); | |
| 108 | + getMachine[SymbolToPrimitive] = () => getMachine(); | ||
| 103 | 109 | getHomeDirectory[SymbolToPrimitive] = () => getHomeDirectory(); | |
| 104 | 110 | getTotalMem[SymbolToPrimitive] = () => getTotalMem(); | |
| 105 | 111 | getUptime[SymbolToPrimitive] = () => getUptime(); | |
@@ -369,7 +375,8 @@ module.exports = { | |||
| 369 | 375 | type: getOSType, | |
| 370 | 376 | userInfo, | |
| 371 | 377 | uptime: getUptime, | |
| 372 | - version: getOSVersion | ||
| 378 | + version: getOSVersion, | ||
| 379 | + machine: getMachine, | ||
| 373 | 380 | }; | |
| 374 | 381 | ||
| 375 | 382 | ObjectDefineProperties(module.exports, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,12 +86,12 @@ static void GetOSInformation(const FunctionCallbackInfo<Value>& args) { | |||
| 86 | 86 | return args.GetReturnValue().SetUndefined(); | |
| 87 | 87 | } | |
| 88 | 88 | ||
| 89 | - // [sysname, version, release] | ||
| 89 | + // [sysname, version, release, machine] | ||
| 90 | 90 | Local<Value> osInformation[] = { | |
| 91 | - String::NewFromUtf8(env->isolate(), info.sysname).ToLocalChecked(), | ||
| 92 | - String::NewFromUtf8(env->isolate(), info.version).ToLocalChecked(), | ||
| 93 | - String::NewFromUtf8(env->isolate(), info.release).ToLocalChecked() | ||
| 94 | - }; | ||
| 91 | + String::NewFromUtf8(env->isolate(), info.sysname).ToLocalChecked(), | ||
| 92 | + String::NewFromUtf8(env->isolate(), info.version).ToLocalChecked(), | ||
| 93 | + String::NewFromUtf8(env->isolate(), info.release).ToLocalChecked(), | ||
| 94 | + String::NewFromUtf8(env->isolate(), info.machine).ToLocalChecked()}; | ||
| 95 | 95 | ||
| 96 | 96 | args.GetReturnValue().Set(Array::New(env->isolate(), | |
| 97 | 97 | osInformation, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -245,7 +245,7 @@ assert.strictEqual(`${os.tmpdir}`, os.tmpdir()); | |||
| 245 | 245 | assert.strictEqual(`${os.arch}`, os.arch()); | |
| 246 | 246 | assert.strictEqual(`${os.platform}`, os.platform()); | |
| 247 | 247 | assert.strictEqual(`${os.version}`, os.version()); | |
| 248 | - | ||
| 248 | + assert.strictEqual(`${os.machine}`, os.machine()); | ||
| 249 | 249 | assert.strictEqual(+os.totalmem, os.totalmem()); | |
| 250 | 250 | ||
| 251 | 251 | // Assert that the following values are coercible to numbers. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments