New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bedard/types

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bedard/types - npm Package Compare versions

Comparing version 0.8.3 to 0.9.0

4

CHANGELOG.md
# Changelog
## 0.9.0
- Add array support to [`ValueOf<T>`](https://github.com/scottbedard/types#valueoft)
## 0.8.3

@@ -4,0 +8,0 @@

2

package.json

@@ -26,3 +26,3 @@ {

},
"version": "0.8.3"
"version": "0.9.0"
}

@@ -434,3 +434,3 @@ # `@bedard/types`

Generate a union from the values of `T`. This can be thought of as an opposite to the [`keyof`](https://www.typescriptlang.org/docs/handbook/2/keyof-types.html) operator.
Generate a union from the values of `T`.

@@ -440,3 +440,5 @@ ```ts

type Values = ValueOf<{ foo: number, bar: string }> // number | string
type ArrayValues = ValueOf<Array<string>> // string
type ObjectValues = ValueOf<{ foo: number, bar: string }> // number | string
```

@@ -443,0 +445,0 @@

@@ -40,2 +40,2 @@ export { AllEqual } from './AllEqual'

export const version = '0.8.3'
export const version = '0.9.0'

@@ -5,4 +5,9 @@ /**

* @example
* ValueOf<Array<string>> // string
* ValuesOf<{ foo: number, bar: string }> // number | string
*/
export type ValueOf<T extends object> = T[keyof T]
export type ValueOf<T extends object | Array<any>> = T extends Array<infer U>
? U
: T extends object
? T[keyof T]
: never

@@ -8,5 +8,13 @@ import {

describe('ValueOf', () => {
it('array', () => {
type T = Array<number | string>
type Test = Expect<Equal<number | string, ValueOf<T>>>
})
it('object', () => {
type Test = Expect<Equal<number | string, ValueOf<{ foo: number, bar: string }>>>
type T = { foo: number, bar: string };
type Test = Expect<Equal<number | string, ValueOf<T>>>
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc