Skip to content

Commit

Permalink
Docs feedback (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
jscheiny authored Apr 7, 2019
1 parent 3ef69a2 commit 35eee07
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/defining-quantities.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ const Velocity = Length.over(Time);
type Velocity<N = number> = LiftMeasure<typeof Velocity, N>;
```

This way, we can use `Velocity` to refer to the quantity on numbers, but also use `Velocity<WrappedNumber>` to operate on `WrappedMeasure`s.
This way, we can use `Velocity` to refer to the quantity on numbers, but also use `Velocity<WrappedNumber>` to operate on `WrappedMeasure` types.
6 changes: 3 additions & 3 deletions docs/generic-measures.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function wrap(value: number) {
}
```

Now we're going to create our own measure type that operates on `WrappedNumber`s, let's call it `WrappedMeasure`:
Now we're going to create our own measure type that operates on `WrappedNumber` types, let's call it `WrappedMeasure`:

```ts
import { createMeasureType, GenericMeasure, Unit } from "safe-units";
Expand Down Expand Up @@ -61,11 +61,11 @@ After we've defined the type of `WrappedMeasure` we now define the class itself

## Usage

The returned `WrappedMeasure` now behaves just like `Measure` does except in the domain of wrapped numbers. This means we can call `WrappedMeasure.dimension` or `WrappedMeasure.of` just as expected. It's important to note that the provided quantities and units (`Length`, `Time`, `meters`, `seconds`, etc) will need to be redefined for other measure types as these types are all specific to `number`s.
The returned `WrappedMeasure` now behaves just like `Measure` does except in the domain of wrapped numbers. This means we can call `WrappedMeasure.dimension` or `WrappedMeasure.of` just as expected. It's important to note that the provided quantities and units (`Length`, `Time`, `meters`, `seconds`, etc) will need to be redefined for other measure types as these types are all specific to `number`.

## Static Methods

By default, generic measures come with a set of static methods that can be applied to measures of all numeric types. However, certain static methods may only make sense for a given numeric type. For example the `Measure.trunc` method exists because `Math.trunc` applies to `number`s. To add static methods to a generic measure type, simple pass an object as a second argument to `createMeasureType`:
By default, generic measures come with a set of static methods that can be applied to measures of all numeric types. However, certain static methods may only make sense for a given numeric type. For example the `Measure.trunc` method exists because `Math.trunc` applies to `number` types. To add static methods to a generic measure type, simple pass an object as a second argument to `createMeasureType`:

```ts
declare function foo(value: WrappedNumber): WrappedNumber;
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const error: Velocity = length.times(time);

Safe units is written in TypeScript and should be consumed by TypeScript users to take full advantage of what it provides. In addition you will need the following:

- TypeScript 2.9 or later
- Strict null checks enabled for your project
- [TypeScript](http://www.typescriptlang.org/) 2.9 or later
- [Strict null checks](https://www.typescriptlang.org/docs/handbook/compiler-options.html) enabled for your project

## Installation

Expand Down
3 changes: 2 additions & 1 deletion docsgen/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ const CodeInline = component("code-line", "code", {
});

export const Link = component("link", "a", {
color: "#00B3A4",
color: "#BF8C0A",
textDecoration: "none",
$nest: {
"&:hover": {
color: "#A67908",
textDecoration: "underline",
},
},
Expand Down

0 comments on commit 35eee07

Please sign in to comment.