Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Utility functions for working with typescript's AST
  2. [![Greenkeeper badge](https://badges.greenkeeper.io/ajafff/tsutils.svg)](https://greenkeeper.io/)
  3. ## Usage
  4. This package consists of two major parts: utilities and typeguard functions.
  5. By importing the project you will get both of them.
  6. ```js
  7. import * as utils from "tsutils";
  8. utils.isIdentifier(node); // typeguard
  9. utils.getLineRanges(sourceFile); // utilities
  10. ```
  11. If you don't need everything offered by this package, you can select what should be imported. The parts that are not imported are never read from disk and may save some startup time and reduce memory consumtion.
  12. If you only need typeguards you can explicitly import them:
  13. ```js
  14. import { isIdentifier } from "tsutils/typeguard";
  15. // You can even distiguish between typeguards for nodes and types
  16. import { isUnionTypeNode } from "tsutils/typeguard/node";
  17. import { isUnionType } from "tsutils/typeguard/type";
  18. ```
  19. If you only need the utilities you can also explicitly import them:
  20. ```js
  21. import { forEachComment, forEachToken } from "tsutils/util";
  22. ```
  23. ### Typescript version dependency
  24. This package is backwards compatible with typescript 2.8.0 at runtime although compiling might need a newer version of typescript installed.
  25. Using `typescript@next` might work, but it's not officially supported. If you encounter any bugs, please open an issue.
  26. For compatibility with older versions of TypeScript typeguard functions are separated by TypeScript version. If you are stuck on `typescript@2.8`, you should import directly from the submodule for that version:
  27. ```js
  28. // all typeguards compatible with typescript@2.8
  29. import { isIdentifier } from "tsutils/typeguard/2.8";
  30. // you can even use nested submodules
  31. import { isIdentifier } from "tsutils/typeguard/2.8/node";
  32. // all typeguards compatible with typescript@2.9 (includes those of 2.8)
  33. import { isIdentifier } from "tsutils/typeguard/2.9";
  34. // always points to the latest stable version (2.9 as of writing this)
  35. import { isIdentifier } from "tsutils/typeguard";
  36. import { isIdentifier } from "tsutils";
  37. // always points to the typeguards for the next TypeScript version (3.0 as of writing this)
  38. import { isIdentifier } from "tsutils/typeguard/next";
  39. ```
  40. Note that if you are also using utility functions, you should prefer the relevant submodule:
  41. ```js
  42. // importing directly from 'tsutils' would pull in the latest typeguards
  43. import { forEachToken } from 'tsutils/util';
  44. import { isIdentifier } from 'tsutils/typeguard/2.8';
  45. ```