breakpoint-changes-rx
Advanced tools
Comparing version 3.5.0 to 3.5.1
import { BehaviorSubject } from 'rxjs'; | ||
import parseBreakpoints from './parseBreakpoints.js'; | ||
import type * as types from './types.js'; | ||
@@ -10,3 +9,3 @@ export type BreakpointDefinition = types.BreakpointDefinition; | ||
curr: K[]; | ||
prev: K_1[]; | ||
prev: K[]; | ||
}>; | ||
@@ -54,2 +53,2 @@ breakpointsChangesBehavior$: BehaviorSubject<{ | ||
export default breakpoints; | ||
export { parseBreakpoints }; | ||
export { default as parseBreakpoints } from './parse-breakpoints.js'; |
import { BehaviorSubject } from 'rxjs'; | ||
import { filter, map, bufferTime, share, } from 'rxjs/operators'; | ||
import parseBreakpoints from './parseBreakpoints.js'; | ||
import fromBreakpointDefinitions from './fromBreakpointDefinitions.js'; | ||
import breakpointHits from './breakpointHits.js'; | ||
import fromBreakpointDefinitions from './from-breakpoint-definitions.js'; | ||
import breakpointHits from './breakpoint-hits.js'; | ||
const breakpoints = (breakpointDefinitions) => { | ||
@@ -75,2 +74,2 @@ const initialBreakpoints = []; | ||
export default breakpoints; | ||
export { parseBreakpoints }; | ||
export { default as parseBreakpoints } from './parse-breakpoints.js'; |
@@ -23,5 +23,7 @@ import { vi, describe, expect, it, } from 'vitest'; | ||
] | ||
.filter(([, val]) => val) | ||
.map(([str, val]) => `(${str}-width: ${val})`) | ||
.join(' and '))).reduce((prev, curr) => curr, ''); | ||
.filter(([, value]) => value) | ||
.map(([string_, value]) => `(${string_}-width: ${value})`) | ||
.join(' and ')) | ||
// eslint-disable-next-line unicorn/no-array-reduce | ||
).reduce((previous, current) => current, ''); | ||
const mockMatchMedia = (matches) => { | ||
@@ -36,3 +38,3 @@ const matchMediaQueries = []; | ||
media: query, | ||
onchange: null, | ||
onchange: undefined, | ||
addEventListener: (event, fnc) => { | ||
@@ -147,5 +149,5 @@ mqlListeners.set(query, fnc); | ||
// are the correct media queries used? | ||
(['sm', 'md', 'lg', 'xl']).forEach((bpName) => { | ||
for (const bpName of ['sm', 'md', 'lg', 'xl']) { | ||
expect(matchMediaQueries).toContain(mqFor(bpName, TEST_BREAKPOINT_DATA)); | ||
}); | ||
} | ||
expect(listenerMock).toHaveBeenCalledTimes(4); // listeners for all media queries added? | ||
@@ -163,12 +165,12 @@ expect(bp.getCurrentBreakpoints()).toStrictEqual(['lg']); | ||
// includesBreakpoint() | ||
['sm', 'md', 'lg', 'xl', 'foo'].forEach((bpName) => { | ||
for (const bpName of ['sm', 'md', 'lg', 'xl', 'foo']) { | ||
expect(bp.includesBreakpoint(bpName)).toBe(bpName === 'lg'); | ||
}); | ||
} | ||
// includesBreakpoints() | ||
[ | ||
for (const bpNames of [ | ||
['sm'], ['md'], ['lg'], ['xl'], ['foo'], | ||
['sm', 'md'], ['lg', 'xl'], | ||
].forEach((bpNames) => { | ||
]) { | ||
expect(bp.includesBreakpoints(bpNames)).toBe(bpNames.includes('lg')); | ||
}); | ||
} | ||
}); | ||
@@ -188,19 +190,19 @@ it('initializes with multiple detected breakpoints', () => { | ||
expect(bpBehaviorSubscriber.mock.calls[0][0]).toStrictEqual({ curr: ['md', 'mdx'], prev: [] }); | ||
['sm', 'md', 'mdx', 'mdy', 'lg', 'xl'].forEach((bpName) => { | ||
for (const bpName of ['sm', 'md', 'mdx', 'mdy', 'lg', 'xl']) { | ||
expect(matchMediaQueries).toContain(mqFor(bpName, TEST_BREAKPOINT_DATA_MULTIPLE_MATCHES)); | ||
}); | ||
} | ||
expect(listenerMock).toHaveBeenCalledTimes(6); | ||
expect(bp.getCurrentBreakpoints()).toStrictEqual(['md', 'mdx']); | ||
// includesBreakpoint() | ||
['sm', 'md', 'mdx', 'mdy', 'lg', 'xl', 'foo'].forEach((bpName) => { | ||
for (const bpName of ['sm', 'md', 'mdx', 'mdy', 'lg', 'xl', 'foo']) { | ||
expect(bp.includesBreakpoint(bpName)).toBe(['md', 'mdx'].includes(bpName)); | ||
}); | ||
} | ||
// includesBreakpoints() | ||
[ | ||
for (const bpNames of [ | ||
['sm'], ['md'], ['mdx'], ['mdy'], ['lg'], ['xl'], ['foo'], | ||
['sm', 'md'], ['md', 'mdx'], ['md', 'mdy'], ['md', 'lg'], ['mdx', 'mdy'], ['mdy', 'lg'], ['lg', 'xl'], | ||
].forEach((bpNames) => { | ||
]) { | ||
expect(bp.includesBreakpoints(bpNames)).toBe(bpNames.includes('md') | ||
|| bpNames.includes('mdx')); | ||
}); | ||
} | ||
}); | ||
@@ -207,0 +209,0 @@ it('initializes with number values for a breakpoint', () => { |
@@ -10,3 +10,3 @@ export interface BreakpointDefinition { | ||
groupMinMax?: number; | ||
isMin: (val: string) => boolean; | ||
isMin: (value: string) => boolean; | ||
} |
{ | ||
"name": "breakpoint-changes-rx", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"repository": { | ||
@@ -32,3 +32,2 @@ "type": "git", | ||
"commit": "cz", | ||
"_postinstall": "husky", | ||
"prepack": "pinst --disable", | ||
@@ -43,3 +42,3 @@ "postpack": "pinst --enable", | ||
"@eslint/eslintrc": "^3.0.2", | ||
"@jenssimon/eslint-config-base": "^7.3.1", | ||
"@jenssimon/eslint-config-base": "^8.0.0", | ||
"@jenssimon/eslint-config-typescript": "^5.2.2", | ||
@@ -50,3 +49,3 @@ "@vitest/coverage-v8": "2.1.8", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.52.0", | ||
"eslint": "^9.0.0", | ||
"husky": "^9.0.0", | ||
@@ -64,3 +63,3 @@ "lint-staged": "^15.0.2", | ||
}, | ||
"packageManager": "yarn@4.5.3", | ||
"packageManager": "yarn@4.6.0", | ||
"config": { | ||
@@ -67,0 +66,0 @@ "commitizen": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35239
0