版博士V2.0程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # detect-libc
  2. Node.js module to detect details of the C standard library (libc)
  3. implementation provided by a given Linux system.
  4. Currently supports detection of GNU glibc and MUSL libc.
  5. Provides asychronous and synchronous functions for the
  6. family (e.g. `glibc`, `musl`) and version (e.g. `1.23`, `1.2.3`).
  7. For previous v1.x releases, please see the
  8. [v1](https://github.com/lovell/detect-libc/tree/v1) branch.
  9. ## Install
  10. ```sh
  11. npm install detect-libc
  12. ```
  13. ## API
  14. ### GLIBC
  15. ```ts
  16. const GLIBC: string = 'glibc';
  17. ```
  18. A String constant containing the value `glibc`.
  19. ### MUSL
  20. ```ts
  21. const MUSL: string = 'musl';
  22. ```
  23. A String constant containing the value `musl`.
  24. ### family
  25. ```ts
  26. function family(): Promise<string | null>;
  27. ```
  28. Resolves asychronously with:
  29. * `glibc` or `musl` when the libc family can be determined
  30. * `null` when the libc family cannot be determined
  31. * `null` when run on a non-Linux platform
  32. ```js
  33. const { family, GLIBC, MUSL } = require('detect-libc');
  34. switch (await family()) {
  35. case GLIBC: ...
  36. case MUSL: ...
  37. case null: ...
  38. }
  39. ```
  40. ### familySync
  41. ```ts
  42. function familySync(): string | null;
  43. ```
  44. Synchronous version of `family()`.
  45. ```js
  46. const { familySync, GLIBC, MUSL } = require('detect-libc');
  47. switch (familySync()) {
  48. case GLIBC: ...
  49. case MUSL: ...
  50. case null: ...
  51. }
  52. ```
  53. ### version
  54. ```ts
  55. function version(): Promise<string | null>;
  56. ```
  57. Resolves asychronously with:
  58. * The version when it can be determined
  59. * `null` when the libc family cannot be determined
  60. * `null` when run on a non-Linux platform
  61. ```js
  62. const { version } = require('detect-libc');
  63. const v = await version();
  64. if (v) {
  65. const [major, minor, patch] = v.split('.');
  66. }
  67. ```
  68. ### versionSync
  69. ```ts
  70. function versionSync(): string | null;
  71. ```
  72. Synchronous version of `version()`.
  73. ```js
  74. const { versionSync } = require('detect-libc');
  75. const v = versionSync();
  76. if (v) {
  77. const [major, minor, patch] = v.split('.');
  78. }
  79. ```
  80. ### isNonGlibcLinux
  81. ```ts
  82. function isNonGlibcLinux(): Promise<boolean>;
  83. ```
  84. Resolves asychronously with:
  85. * `false` when the libc family is `glibc`
  86. * `true` when the libc family is not `glibc`
  87. * `false` when run on a non-Linux platform
  88. ```js
  89. const { isNonGlibcLinux } = require('detect-libc');
  90. if (await isNonGlibcLinux()) { ... }
  91. ```
  92. ### isNonGlibcLinuxSync
  93. ```ts
  94. function isNonGlibcLinuxSync(): boolean;
  95. ```
  96. Synchronous version of `isNonGlibcLinux()`.
  97. ```js
  98. const { isNonGlibcLinuxSync } = require('detect-libc');
  99. if (isNonGlibcLinuxSync()) { ... }
  100. ```
  101. ## Licensing
  102. Copyright 2017, 2022 Lovell Fuller
  103. Licensed under the Apache License, Version 2.0 (the "License");
  104. you may not use this file except in compliance with the License.
  105. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
  106. Unless required by applicable law or agreed to in writing, software
  107. distributed under the License is distributed on an "AS IS" BASIS,
  108. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  109. See the License for the specific language governing permissions and
  110. limitations under the License.