An open API service indexing awesome lists of open source software.

https://github.com/narumincho/readonly

TypeScript readonly type
https://github.com/narumincho/readonly

deno immutable typescript

Last synced: 4 months ago
JSON representation

TypeScript readonly type

Awesome Lists containing this project

README

          

# @narumincho/readonly

https://jsr.io/@narumincho/readonly

TypeScript readonly type

- ReadonlyURL
- ReadonlyURLSearchParams
- ReadonlyUint8Array

## Example

```ts
const url = new URL("https://example.com");
func(url);
console.log(url); // https://example.com/aaa

const func = (url: URL): void => {
url.pathname = "/aaa";
};
```

```ts
import type { ReadonlyURL } from "jsr:@narumincho/readonly";

const url = new URL("https://example.com");
func(url);
console.log(url);

const func = (url: ReadonlyURL): void => {
url.pathname = "/aaa"; // Cannot assign to 'pathname' because it is a read-only property.
};
```

With `jsr:@narumincho/readonly`, URLs can be guaranteed not to be overwritten