@contember/utilities 2.0.0-alpha.19 → 2.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/index.cjs +0 -29
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +1 -30
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/structures/BijectiveIndexedMap.cjs.map +1 -1
- package/dist/development/src/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/development/src/structures/LRUCache.cjs.map +1 -1
- package/dist/development/src/structures/LRUCache.js.map +1 -1
- package/dist/production/index.cjs +0 -29
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +1 -30
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/structures/BijectiveIndexedMap.cjs.map +1 -1
- package/dist/production/src/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/production/src/structures/LRUCache.cjs.map +1 -1
- package/dist/production/src/structures/LRUCache.js.map +1 -1
- package/dist/types/assert-types/index.d.ts +0 -4
- package/dist/types/assert-types/index.d.ts.map +1 -1
- package/dist/types/dom/index.d.ts +0 -4
- package/dist/types/dom/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/structures/BijectiveIndexedMap.d.ts +4 -4
- package/dist/types/structures/BijectiveIndexedMap.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/assert-types/index.ts +0 -4
- package/src/dom/index.ts +0 -4
- package/src/index.ts +0 -6
- package/src/structures/BijectiveIndexedMap.ts +4 -4
- package/src/structures/LRUCache.ts +1 -1
- package/src/types/index.ts +0 -1
- package/dist/development/src/assert-types/AssertionError.cjs +0 -9
- package/dist/development/src/assert-types/AssertionError.cjs.map +0 -1
- package/dist/development/src/assert-types/AssertionError.js +0 -9
- package/dist/development/src/assert-types/AssertionError.js.map +0 -1
- package/dist/development/src/assert-types/Predicates.cjs +0 -7
- package/dist/development/src/assert-types/Predicates.cjs.map +0 -1
- package/dist/development/src/assert-types/Predicates.js +0 -7
- package/dist/development/src/assert-types/Predicates.js.map +0 -1
- package/dist/development/src/assert-types/assert.cjs +0 -10
- package/dist/development/src/assert-types/assert.cjs.map +0 -1
- package/dist/development/src/assert-types/assert.js +0 -10
- package/dist/development/src/assert-types/assert.js.map +0 -1
- package/dist/development/src/css-utilities/px.cjs +0 -7
- package/dist/development/src/css-utilities/px.cjs.map +0 -1
- package/dist/development/src/css-utilities/px.js +0 -7
- package/dist/development/src/css-utilities/px.js.map +0 -1
- package/dist/development/src/data-utilities/dateToStringWithoutTimezone.cjs +0 -20
- package/dist/development/src/data-utilities/dateToStringWithoutTimezone.cjs.map +0 -1
- package/dist/development/src/data-utilities/dateToStringWithoutTimezone.js +0 -20
- package/dist/development/src/data-utilities/dateToStringWithoutTimezone.js.map +0 -1
- package/dist/development/src/dom/getElementDimensions.cjs +0 -22
- package/dist/development/src/dom/getElementDimensions.cjs.map +0 -1
- package/dist/development/src/dom/getElementDimensions.js +0 -22
- package/dist/development/src/dom/getElementDimensions.js.map +0 -1
- package/dist/development/src/dom/getSizeFromResizeObserverEntry.cjs +0 -24
- package/dist/development/src/dom/getSizeFromResizeObserverEntry.cjs.map +0 -1
- package/dist/development/src/dom/getSizeFromResizeObserverEntry.js +0 -24
- package/dist/development/src/dom/getSizeFromResizeObserverEntry.js.map +0 -1
- package/dist/development/src/dom/shouldCancelStart.cjs +0 -29
- package/dist/development/src/dom/shouldCancelStart.cjs.map +0 -1
- package/dist/development/src/dom/shouldCancelStart.js +0 -29
- package/dist/development/src/dom/shouldCancelStart.js.map +0 -1
- package/dist/development/src/dom/stateDataAttributes.cjs +0 -11
- package/dist/development/src/dom/stateDataAttributes.cjs.map +0 -1
- package/dist/development/src/dom/stateDataAttributes.js +0 -11
- package/dist/development/src/dom/stateDataAttributes.js.map +0 -1
- package/dist/development/src/events/isSpecialLinkClick.cjs +0 -5
- package/dist/development/src/events/isSpecialLinkClick.cjs.map +0 -1
- package/dist/development/src/events/isSpecialLinkClick.js +0 -5
- package/dist/development/src/events/isSpecialLinkClick.js.map +0 -1
- package/dist/development/src/functional/omit.cjs +0 -15
- package/dist/development/src/functional/omit.cjs.map +0 -1
- package/dist/development/src/functional/omit.js +0 -15
- package/dist/development/src/functional/omit.js.map +0 -1
- package/dist/development/src/functional/pick.cjs +0 -15
- package/dist/development/src/functional/pick.cjs.map +0 -1
- package/dist/development/src/functional/pick.js +0 -15
- package/dist/development/src/functional/pick.js.map +0 -1
- package/dist/development/src/functional/range.cjs +0 -7
- package/dist/development/src/functional/range.cjs.map +0 -1
- package/dist/development/src/functional/range.js +0 -7
- package/dist/development/src/functional/range.js.map +0 -1
- package/dist/development/src/string-utilities/kebabCase.cjs +0 -8
- package/dist/development/src/string-utilities/kebabCase.cjs.map +0 -1
- package/dist/development/src/string-utilities/kebabCase.js +0 -8
- package/dist/development/src/string-utilities/kebabCase.js.map +0 -1
- package/dist/production/src/assert-types/AssertionError.cjs +0 -9
- package/dist/production/src/assert-types/AssertionError.cjs.map +0 -1
- package/dist/production/src/assert-types/AssertionError.js +0 -9
- package/dist/production/src/assert-types/AssertionError.js.map +0 -1
- package/dist/production/src/assert-types/Predicates.cjs +0 -7
- package/dist/production/src/assert-types/Predicates.cjs.map +0 -1
- package/dist/production/src/assert-types/Predicates.js +0 -7
- package/dist/production/src/assert-types/Predicates.js.map +0 -1
- package/dist/production/src/assert-types/assert.cjs +0 -10
- package/dist/production/src/assert-types/assert.cjs.map +0 -1
- package/dist/production/src/assert-types/assert.js +0 -10
- package/dist/production/src/assert-types/assert.js.map +0 -1
- package/dist/production/src/css-utilities/px.cjs +0 -7
- package/dist/production/src/css-utilities/px.cjs.map +0 -1
- package/dist/production/src/css-utilities/px.js +0 -7
- package/dist/production/src/css-utilities/px.js.map +0 -1
- package/dist/production/src/data-utilities/dateToStringWithoutTimezone.cjs +0 -20
- package/dist/production/src/data-utilities/dateToStringWithoutTimezone.cjs.map +0 -1
- package/dist/production/src/data-utilities/dateToStringWithoutTimezone.js +0 -20
- package/dist/production/src/data-utilities/dateToStringWithoutTimezone.js.map +0 -1
- package/dist/production/src/dom/getElementDimensions.cjs +0 -22
- package/dist/production/src/dom/getElementDimensions.cjs.map +0 -1
- package/dist/production/src/dom/getElementDimensions.js +0 -22
- package/dist/production/src/dom/getElementDimensions.js.map +0 -1
- package/dist/production/src/dom/getSizeFromResizeObserverEntry.cjs +0 -24
- package/dist/production/src/dom/getSizeFromResizeObserverEntry.cjs.map +0 -1
- package/dist/production/src/dom/getSizeFromResizeObserverEntry.js +0 -24
- package/dist/production/src/dom/getSizeFromResizeObserverEntry.js.map +0 -1
- package/dist/production/src/dom/shouldCancelStart.cjs +0 -29
- package/dist/production/src/dom/shouldCancelStart.cjs.map +0 -1
- package/dist/production/src/dom/shouldCancelStart.js +0 -29
- package/dist/production/src/dom/shouldCancelStart.js.map +0 -1
- package/dist/production/src/dom/stateDataAttributes.cjs +0 -11
- package/dist/production/src/dom/stateDataAttributes.cjs.map +0 -1
- package/dist/production/src/dom/stateDataAttributes.js +0 -11
- package/dist/production/src/dom/stateDataAttributes.js.map +0 -1
- package/dist/production/src/events/isSpecialLinkClick.cjs +0 -5
- package/dist/production/src/events/isSpecialLinkClick.cjs.map +0 -1
- package/dist/production/src/events/isSpecialLinkClick.js +0 -5
- package/dist/production/src/events/isSpecialLinkClick.js.map +0 -1
- package/dist/production/src/functional/omit.cjs +0 -15
- package/dist/production/src/functional/omit.cjs.map +0 -1
- package/dist/production/src/functional/omit.js +0 -15
- package/dist/production/src/functional/omit.js.map +0 -1
- package/dist/production/src/functional/pick.cjs +0 -15
- package/dist/production/src/functional/pick.cjs.map +0 -1
- package/dist/production/src/functional/pick.js +0 -15
- package/dist/production/src/functional/pick.js.map +0 -1
- package/dist/production/src/functional/range.cjs +0 -7
- package/dist/production/src/functional/range.cjs.map +0 -1
- package/dist/production/src/functional/range.js +0 -7
- package/dist/production/src/functional/range.js.map +0 -1
- package/dist/production/src/string-utilities/kebabCase.cjs +0 -8
- package/dist/production/src/string-utilities/kebabCase.cjs.map +0 -1
- package/dist/production/src/string-utilities/kebabCase.js +0 -8
- package/dist/production/src/string-utilities/kebabCase.js.map +0 -1
- package/dist/types/assert-types/AssertionError.d.ts +0 -4
- package/dist/types/assert-types/AssertionError.d.ts.map +0 -1
- package/dist/types/assert-types/Predicates.d.ts +0 -2
- package/dist/types/assert-types/Predicates.d.ts.map +0 -1
- package/dist/types/assert-types/assert.d.ts +0 -3
- package/dist/types/assert-types/assert.d.ts.map +0 -1
- package/dist/types/assert-types/types.d.ts +0 -2
- package/dist/types/assert-types/types.d.ts.map +0 -1
- package/dist/types/css-utilities/index.d.ts +0 -2
- package/dist/types/css-utilities/index.d.ts.map +0 -1
- package/dist/types/css-utilities/px.d.ts +0 -8
- package/dist/types/css-utilities/px.d.ts.map +0 -1
- package/dist/types/data-utilities/dateToStringWithoutTimezone.d.ts +0 -4
- package/dist/types/data-utilities/dateToStringWithoutTimezone.d.ts.map +0 -1
- package/dist/types/data-utilities/index.d.ts +0 -2
- package/dist/types/data-utilities/index.d.ts.map +0 -1
- package/dist/types/dom/getElementDimensions.d.ts +0 -14
- package/dist/types/dom/getElementDimensions.d.ts.map +0 -1
- package/dist/types/dom/getSizeFromResizeObserverEntry.d.ts +0 -5
- package/dist/types/dom/getSizeFromResizeObserverEntry.d.ts.map +0 -1
- package/dist/types/dom/shouldCancelStart.d.ts +0 -4
- package/dist/types/dom/shouldCancelStart.d.ts.map +0 -1
- package/dist/types/dom/stateDataAttributes.d.ts +0 -4
- package/dist/types/dom/stateDataAttributes.d.ts.map +0 -1
- package/dist/types/events/index.d.ts +0 -2
- package/dist/types/events/index.d.ts.map +0 -1
- package/dist/types/events/isSpecialLinkClick.d.ts +0 -2
- package/dist/types/events/isSpecialLinkClick.d.ts.map +0 -1
- package/dist/types/functional/index.d.ts +0 -4
- package/dist/types/functional/index.d.ts.map +0 -1
- package/dist/types/functional/omit.d.ts +0 -2
- package/dist/types/functional/omit.d.ts.map +0 -1
- package/dist/types/functional/pick.d.ts +0 -2
- package/dist/types/functional/pick.d.ts.map +0 -1
- package/dist/types/functional/range.d.ts +0 -9
- package/dist/types/functional/range.d.ts.map +0 -1
- package/dist/types/string-utilities/index.d.ts +0 -2
- package/dist/types/string-utilities/index.d.ts.map +0 -1
- package/dist/types/string-utilities/kebabCase.d.ts +0 -2
- package/dist/types/string-utilities/kebabCase.d.ts.map +0 -1
- package/dist/types/types/PolymorphicRefs.d.ts +0 -47
- package/dist/types/types/PolymorphicRefs.d.ts.map +0 -1
- package/src/assert-types/AssertionError.ts +0 -5
- package/src/assert-types/Predicates.ts +0 -3
- package/src/assert-types/assert.ts +0 -15
- package/src/assert-types/types.ts +0 -1
- package/src/css-utilities/index.ts +0 -1
- package/src/css-utilities/px.ts +0 -9
- package/src/data-utilities/dateToStringWithoutTimezone.ts +0 -18
- package/src/data-utilities/index.ts +0 -1
- package/src/dom/getElementDimensions.ts +0 -36
- package/src/dom/getSizeFromResizeObserverEntry.ts +0 -26
- package/src/dom/shouldCancelStart.ts +0 -32
- package/src/dom/stateDataAttributes.ts +0 -8
- package/src/events/index.ts +0 -1
- package/src/events/isSpecialLinkClick.ts +0 -1
- package/src/functional/index.ts +0 -3
- package/src/functional/omit.ts +0 -13
- package/src/functional/pick.ts +0 -13
- package/src/functional/range.ts +0 -11
- package/src/string-utilities/index.ts +0 -1
- package/src/string-utilities/kebabCase.ts +0 -5
- package/src/types/PolymorphicRefs.ts +0 -70
- package/tests/css-utilities/px.test.ts +0 -12
- package/tests/deprecate/deprecate.test.ts +0 -53
- package/tests/functional/omit.test.ts +0 -20
- package/tests/functional/pick.test.ts +0 -12
- package/tests/functional/range.test.ts +0 -12
package/src/functional/range.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Get a list of numbers between start and end, inclusive, with the given step size (defaulting to 1)
|
|
4
|
-
* @param start - The starting number.
|
|
5
|
-
* @param end - The ending number.
|
|
6
|
-
* @param step - The step size, optional, defaults to 1.
|
|
7
|
-
* @returns A list of numbers between start and end, inclusive, with the given step size (defaulting to 1)
|
|
8
|
-
*/
|
|
9
|
-
export function range(start: number, end: number, step = 1): number[] {
|
|
10
|
-
return Array.from({ length: Math.floor(Math.abs(end - start) / step) + 1 }, (_, i) => start + i * (end > start ? 1 : -1) * Math.abs(step))
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './kebabCase'
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Source: https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
|
|
2
|
-
|
|
3
|
-
// Source: https://github.com/emotion-js/emotion/blob/master/packages/styled-base/types/helper.d.ts
|
|
4
|
-
// A more precise version of just React.ComponentPropsWithoutRef on its own
|
|
5
|
-
import { ReactNode } from 'react'
|
|
6
|
-
|
|
7
|
-
export type PropsOf<
|
|
8
|
-
C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>
|
|
9
|
-
> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>
|
|
10
|
-
|
|
11
|
-
export type AsProp<C extends React.ElementType> = {
|
|
12
|
-
/**
|
|
13
|
-
* An override of the default HTML tag.
|
|
14
|
-
* Can also be another React component.
|
|
15
|
-
*/
|
|
16
|
-
as?: C
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
|
|
21
|
-
* (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
|
|
22
|
-
* set of props.
|
|
23
|
-
*/
|
|
24
|
-
export type ExtendableProps<
|
|
25
|
-
ExtendedProps = {},
|
|
26
|
-
OverrideProps = {}
|
|
27
|
-
> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Allows for inheriting the props from the specified element type so that
|
|
31
|
-
* props like children, className & style work, as well as element-specific
|
|
32
|
-
* attributes like aria roles. The component (`C`) must be passed in.
|
|
33
|
-
*/
|
|
34
|
-
export type InheritableElementProps<
|
|
35
|
-
C extends React.ElementType,
|
|
36
|
-
Props = {}
|
|
37
|
-
> = ExtendableProps<PropsOf<C>, Props>
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A more sophisticated version of `InheritableElementProps` where
|
|
41
|
-
* the passed in `as` prop will determine which props can be included
|
|
42
|
-
*/
|
|
43
|
-
export type PolymorphicComponentProps<
|
|
44
|
-
C extends React.ElementType,
|
|
45
|
-
Props = {}
|
|
46
|
-
> = InheritableElementProps<C, Props & AsProp<C>>
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Utility type to extract the `ref` prop from a polymorphic component
|
|
50
|
-
*/
|
|
51
|
-
export type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>['ref']
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* A wrapper of `PolymorphicComponentProps` that also includes the `ref`
|
|
55
|
-
* prop for the polymorphic component
|
|
56
|
-
*/
|
|
57
|
-
export type PolymorphicComponentPropsWithRef<
|
|
58
|
-
C extends React.ElementType,
|
|
59
|
-
Props = {}
|
|
60
|
-
> = PolymorphicComponentProps<C, Props> & { ref?: PolymorphicRef<C> }
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* A polymorphic component is a component that can be rendered as different
|
|
64
|
-
* HTML elements or other React components by specifying the `as` prop.
|
|
65
|
-
* This type allows for specifying the component (`C`) and the props (`P`)
|
|
66
|
-
* that the component accepts.
|
|
67
|
-
*/
|
|
68
|
-
export type PolymorphicComponent<T extends React.ElementType, P = {}> =
|
|
69
|
-
& (<C extends React.ElementType = T>(props: PolymorphicComponentPropsWithRef<C, P>) => ReactNode)
|
|
70
|
-
& { displayName?: string | undefined }
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest'
|
|
2
|
-
import { px } from '../../src'
|
|
3
|
-
|
|
4
|
-
describe('@contember/utilities', function () {
|
|
5
|
-
test('@contember/utilities.px', function () {
|
|
6
|
-
expect(px(100)).equals('100px')
|
|
7
|
-
expect(px(false)).equals('')
|
|
8
|
-
expect(px(null)).equals('')
|
|
9
|
-
expect(px(undefined)).equals('')
|
|
10
|
-
expect(px(NaN)).equals('')
|
|
11
|
-
})
|
|
12
|
-
})
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vitest } from 'vitest'
|
|
2
|
-
import { deprecate } from '../../src'
|
|
3
|
-
|
|
4
|
-
describe('@contember/utilities.deprecate', () => {
|
|
5
|
-
it('logs a warning if the condition is true', () => {
|
|
6
|
-
const spy = vitest.spyOn(console, 'warn').mockImplementation(() => { })
|
|
7
|
-
deprecate('2.0.0', true, 'oldFeature', 'newFeature')
|
|
8
|
-
expect(spy).toHaveBeenCalledWith('Use of oldFeature is deprecated and might be removed in the next release. Use newFeature instead.')
|
|
9
|
-
spy.mockRestore()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('throws an error if strict deprecations are enabled and the condition is true', () => {
|
|
13
|
-
const originalEnv = process.env
|
|
14
|
-
process.env = { ...originalEnv, VITE_CONTEMBER_ADMIN_STRICT_DEPRECATIONS: 'true' }
|
|
15
|
-
expect(() => {
|
|
16
|
-
deprecate('2.0.0', true, 'oldFeature', 'newFeature')
|
|
17
|
-
}).toThrow('Support for oldFeature was planned to be removed in the 2.0.0 release. Replace it with newFeature instead.')
|
|
18
|
-
process.env = originalEnv
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('does not log a warning if the condition is false', () => {
|
|
22
|
-
const spy = vitest.spyOn(console, 'warn').mockImplementation(() => { })
|
|
23
|
-
deprecate('2.0.0', false, 'oldFeature', 'newFeature')
|
|
24
|
-
expect(spy).not.toHaveBeenCalled()
|
|
25
|
-
spy.mockRestore()
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('does not throw an error if strict deprecations are enabled and the condition is false', () => {
|
|
29
|
-
const originalEnv = process.env
|
|
30
|
-
process.env = { ...originalEnv, VITE_CONTEMBER_ADMIN_STRICT_DEPRECATIONS: 'true' }
|
|
31
|
-
expect(() => {
|
|
32
|
-
deprecate('2.0.0', false, 'oldFeature', 'newFeature')
|
|
33
|
-
}).not.toThrow()
|
|
34
|
-
process.env = originalEnv
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('does not log a warning if the condition is true but the environment is not development', () => {
|
|
38
|
-
const originalEnv = process.env
|
|
39
|
-
process.env = { ...originalEnv, DEV: '' }
|
|
40
|
-
const spy = vitest.spyOn(console, 'warn').mockImplementation(() => { })
|
|
41
|
-
deprecate('2.0.0', true, 'oldFeature', 'newFeature')
|
|
42
|
-
expect(spy).not.toHaveBeenCalled()
|
|
43
|
-
spy.mockRestore()
|
|
44
|
-
process.env = originalEnv
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('logs a warning if the condition is true and replacement is null', () => {
|
|
48
|
-
const spy = vitest.spyOn(console, 'warn').mockImplementation(() => { })
|
|
49
|
-
deprecate('2.0.0', true, 'oldFeature', null)
|
|
50
|
-
expect(spy).toHaveBeenCalledWith('Use of oldFeature is deprecated and might be removed in the next release. There is no replacement.')
|
|
51
|
-
spy.mockRestore()
|
|
52
|
-
})
|
|
53
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest'
|
|
2
|
-
import { omit } from '../../src'
|
|
3
|
-
|
|
4
|
-
describe('@contember/utilities', function() {
|
|
5
|
-
test('@contember/utilities.omit', function() {
|
|
6
|
-
let obj = {
|
|
7
|
-
a: 1,
|
|
8
|
-
b: 2,
|
|
9
|
-
c: 3,
|
|
10
|
-
d: 4,
|
|
11
|
-
e: 5,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
expect(omit(obj, ['a'])).toEqual({ b: 2, c: 3, d: 4, e: 5 })
|
|
15
|
-
expect(omit(obj, ['a', 'b'])).toEqual({ c: 3, d: 4, e: 5 })
|
|
16
|
-
expect(omit(obj, ['a', 'b', 'c'])).toEqual({ d: 4, e: 5 })
|
|
17
|
-
expect(omit(obj, ['a', 'b', 'c', 'd'])).toEqual({ e: 5 })
|
|
18
|
-
expect(omit(obj, ['a', 'b', 'c', 'd', 'e'])).toEqual({})
|
|
19
|
-
})
|
|
20
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest'
|
|
2
|
-
import { pick } from '../../src'
|
|
3
|
-
|
|
4
|
-
describe('@contember/utilities', function () {
|
|
5
|
-
test('@contember/utilities.pick', function () {
|
|
6
|
-
const from = { a: 1, b: 2 }
|
|
7
|
-
|
|
8
|
-
expect(pick(from, ['a'])).toEqual({ a: 1 })
|
|
9
|
-
// @ts-expect-error - 'c' does not exist in { a: 1, b: 2 }
|
|
10
|
-
expect(() => pick(from, ['c'])).throws('Key "c" does not exist in object {"a":1,"b":2}')
|
|
11
|
-
})
|
|
12
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest'
|
|
2
|
-
import { range } from '../../src'
|
|
3
|
-
|
|
4
|
-
describe('@contember/utilities', function () {
|
|
5
|
-
test('@contember/utilities.range', function () {
|
|
6
|
-
expect(range(1, 1)).toEqual([1])
|
|
7
|
-
expect(range(1, 4)).toEqual([1, 2, 3, 4])
|
|
8
|
-
expect(range(0, 4, 2)).toEqual([0, 2, 4])
|
|
9
|
-
expect(range(5, 2)).toEqual([5, 4, 3, 2])
|
|
10
|
-
expect(range(5, 2, 2)).toEqual([5, 3])
|
|
11
|
-
})
|
|
12
|
-
})
|