Skip to content

Commit

Permalink
docs(alias): add packages/alias info to main project readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nberlette committed Apr 29, 2024
1 parent b3703e2 commit ce0d3b9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,38 @@ Monorepo for packages published under the [`@decorators/*`][JSR] scope on [JSR].

## Packages

#### [`@decorators/alias`][@decorators/alias]

> Alias class members to simplify stack traces.
```ts
import { alias } from "@decorators/alias";

class Foo {
// alias() can be used to create multiple aliases from one original member
@alias("qux", "nurp")
bar(): string {
return "baz";
}

// declare the aliased members to avoid compilation errors
declare qux: Foo["bar"];
declare nurp: Foo["bar"];

// or, use @alias.for on the alias itself and pass it the original member name.
@alias.for("bar")
baz(): string {
return this.bar();
}
}

const foo = new Foo();

console.assert(foo.bar === "baz"); // OK
console.assert(foo.bar === foo.baz); // OK
console.assert(foo.qux === foo.bar); // OK
console.assert(foo.nurp === foo.bar); // OK
```

#### [`@decorators/bind`][@decorators/bind]

Expand Down Expand Up @@ -40,6 +72,7 @@ console.log(bar() instanceof Foo); // true

</div>

[@decorators/alias]: https://github.com/nberlette/decorators/tree/main/packages/alias#readme "Check out '@decorators/alias' and more over at the GitHub monorepo!"
[@decorators/bind]: https://github.com/nberlette/decorators/tree/main/packages/bind#readme "Check out '@decorators/bind' and more over at the GitHub monorepo!"
[GitHub]: https://github.com/nberlette/decorators/tree/main/packages/bind#readme "Check out all the '@decorators/*' packages over at the GitHub monorepo!"
[MIT]: https://nick.mit-license.org "MIT © 2024+ Nicholas Berlette. All rights reserved."
Expand Down

0 comments on commit ce0d3b9

Please sign in to comment.