| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -452,6 +452,22 @@ On POSIX systems, the operating system release is determined by calling | |||
| 452 | 452 | available, `GetVersionExW()` will be used. See | |
| 453 | 453 | <https://en.wikipedia.org/wiki/Uname#Examples> for more information. | |
| 454 | 454 | ||
| 455 | + ## `os.machine()` | ||
| 456 | + | ||
| 457 | + <!-- YAML | ||
| 458 | + added: REPLACEME | ||
| 459 | + --> | ||
| 460 | + | ||
| 461 | + * Returns {string} | ||
| 462 | + | ||
| 463 | + Returns the machine type as a string, such as `arm`, `aarch64`, `mips`, | ||
| 464 | + `mips64`, `ppc64`, `ppc64le`, `s390`, `s390x`, `i386`, `i686`, `x86_64`. | ||
| 465 | + | ||
| 466 | + On POSIX systems, the machine type is determined by calling | ||
| 467 | + [`uname(3)`][]. On Windows, `RtlGetVersion()` is used, and if it is not | ||
| 468 | + available, `GetVersionExW()` will be used. See | ||
| 469 | + <https://en.wikipedia.org/wiki/Uname#Examples> for more information. | ||
| 470 | + | ||
| 455 | 471 | ## OS constants | |
| 456 | 472 | ||
| 457 | 473 | 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); | |
@@ -92,12 +93,17 @@ const getOSType = () => type; | |||
| 92 | 93 | * @returns {string} | |
| 93 | 94 | */ | |
| 94 | 95 | const getOSVersion = () => version; | |
| 96 | + /** | ||
| 97 | + * @returns {string} | ||
| 98 | + */ | ||
| 99 | + const getMachine = () => machine; | ||
| 95 | 100 | ||
| 96 | 101 | getFreeMem[SymbolToPrimitive] = () => getFreeMem(); | |
| 97 | 102 | getHostname[SymbolToPrimitive] = () => getHostname(); | |
| 98 | 103 | getOSVersion[SymbolToPrimitive] = () => getOSVersion(); | |
| 99 | 104 | getOSType[SymbolToPrimitive] = () => getOSType(); | |
| 100 | 105 | getOSRelease[SymbolToPrimitive] = () => getOSRelease(); | |
| 106 | + getMachine[SymbolToPrimitive] = () => getMachine(); | ||
| 101 | 107 | getHomeDirectory[SymbolToPrimitive] = () => getHomeDirectory(); | |
| 102 | 108 | getTotalMem[SymbolToPrimitive] = () => getTotalMem(); | |
| 103 | 109 | getUptime[SymbolToPrimitive] = () => getUptime(); | |
@@ -367,7 +373,8 @@ module.exports = { | |||
| 367 | 373 | type: getOSType, | |
| 368 | 374 | userInfo, | |
| 369 | 375 | uptime: getUptime, | |
| 370 | - version: getOSVersion | ||
| 376 | + version: getOSVersion, | ||
| 377 | + machine: getMachine, | ||
| 371 | 378 | }; | |
| 372 | 379 | ||
| 373 | 380 | 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