Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/everyday-types
Everyday utility types
https://github.com/stagas/everyday-types
Last synced: 14 days ago
JSON representation
Everyday utility types
- Host: GitHub
- URL: https://github.com/stagas/everyday-types
- Owner: stagas
- License: mit
- Created: 2022-05-03T19:48:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-07T10:40:13.000Z (over 2 years ago)
- Last Synced: 2024-10-13T21:28:10.978Z (about 1 month ago)
- Language: TypeScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
everyday-typesEveryday utility types
npm i everyday-types
pnpm add everyday-types
yarn add everyday-types
## API
#
AAt
src/string.ts#L3
A extends List ? number extends A ["length"
] ? K extends number | template-literal ? A [never] | undefined : undefined : K extends keyof A ? A [K] : undefined : unknown extends A ? unknown : K extends keyof A ? A [K] : undefined
Cast
src/string.ts#L42 # Key
src/string.ts#L1 string | number | symbol
LLength
– Ask TS to re-check that A1
extends A2
.
And if it fails,
A2
will be enforced anyway.
Can also be used to add constraints on parameters. src/string.ts#L40
L ["length"
]
List
src/string.ts#L2 ReadonlyArray<A>
Literal
src/string.ts#L11 string | number | bigint | boolean
Pop
src/string.ts#L63 # _Replace
src/string.ts#L47 # __Split
src/string.ts#L50 # String
src/string.ts#L1 - #
Join
– Concat many literals together src/string.ts#L24 # Length
src/string.ts#L43 # Replace
src/string.ts#L44 # Split
– Split S
by D
into a [[List]] src/string.ts#L62
CustomElement
src/everyday-types.ts#L83 # attributeChangedCallback
(name, oldValue, newValue) – Callback that is invoked when one of the {@link withProperties} changes.
# name
– Name of attribute
string
oldValue
– Old value null
| string
newValue
– New value
null
| string
attributeChangedCallback(name, oldValue, newValue) =>
- void
connectedCallback
() – Invoked when the component is added to the document's DOM.
In `connectedCallback()` you should setup tasks that should only occur when
the element is connected to the document. The most common of these is
adding event listeners to nodes external to the element, like a keydown
event handler added to the window.
```ts
connectedCallback() {
super.connectedCallback();
this.addEventListener('keydown', this._handleKeydown);
}
```
Typically, anything done in `connectedCallback()` should be undone when the
element is disconnected, in `disconnectedCallback()`.
connectedCallback() =>
- void
disconnectedCallback
() – Invoked when the component is removed from the document's DOM.
This callback is the main signal to the element that it may no longer be
used. `disconnectedCallback()` should ensure that nothing is holding a
reference to the element (such as event listeners added to nodes external
to the element), so that it is free to be garbage collected.
```ts
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener('keydown', this._handleKeydown);
}
```
An element may be re-connected after being disconnected.
disconnectedCallback() =>
- void
EventHandler
src/everyday-types.ts#L7 # this
event
E & {
# currentTarget
src/everyday-types.ts#L8
target
src/everyday-types.ts#L8 Element
EventHandler(this, event) =>
- any
SafeMap
src/everyday-types.ts#L62 # has
(v) # SafeWeakMap
src/everyday-types.ts#L67 # has
(v) # Any
src/everyday-types.ts#L60 any
Chunk
src/everyday-types.ts#L3 # Class
src/everyday-types.ts#L5 # (args) src/everyday-types.ts#L5
Ctor
src/everyday-types.ts#L6 # (args) src/everyday-types.ts#L6
CustomElementConstructor
src/everyday-types.ts#L74 Class<CustomElement> & {}
DetailOf
src/everyday-types.ts#L54 # EventKeys
src/everyday-types.ts#L10 # EventsOf
src/everyday-types.ts#L33 # Fn
src/everyday-types.ts#L11 # Get
src/everyday-types.ts#L12 # Key
src/everyday-types.ts#L13 number | string | symbol
Keys
src/everyday-types.ts#L14 # Mixable
src/everyday-types.ts#L15 {} & Omit<T, "constructor"
>
Mutable
src/everyday-types.ts#L16 # Narrow
src/everyday-types.ts#L18 # NarrowKey
src/everyday-types.ts#L17 # NonNull
src/everyday-types.ts#L19 # Null
src/everyday-types.ts#L20 null
| undefined | void
ObjectFromList
src/everyday-types.ts#L22 # Prefix
src/everyday-types.ts#L25 template-literal
SansOn
src/everyday-types.ts#L26 String.Split<StringOf<T>, " on"
>
StringKeys
src/everyday-types.ts#L27 # StringLiteral
src/everyday-types.ts#L28 # StringOf
src/everyday-types.ts#L29 # Target
src/everyday-types.ts#L30 HTMLElement | SVGElement | Window | Document | ShadowRoot
ValueConstructor
src/everyday-types.ts#L72 StringConstructor | NumberConstructor | BooleanConstructor
ValuesOf
src/everyday-types.ts#L31 # _Chunk
src/everyday-types.ts#L4
## Credits
- [ts-toolbelt](https://npmjs.org/package/ts-toolbelt) by [Pierre-Antoine Mills](https://github.com/github.com) – TypeScript's largest utility library
## Contributing
[Fork](https://github.com/stagas/everyday-types/fork) or [edit](https://github.dev/stagas/everyday-types) and submit a PR.
All contributions are welcome!
## License
MIT © 2022 [stagas](https://github.com/stagas)