8000 Merge branch 'main' into 5.x · immutable-js/immutable-js@c1080ad · GitHub
[go: up one dir, main page]

Skip to content

Commit c1080ad

Browse files
committed
Merge branch 'main' into 5.x
2 parents c46db63 + 43052fc commit c1080ad

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
jobs:
99
build:
1010
name: 'Build & Publish to NPM'
11+
permissions:
12+
contents: read
13+
id-token: write
1114
runs-on: ubuntu-latest
1215
steps:
1316
- uses: actions/checkout@v2
@@ -22,6 +25,15 @@ jobs:
2225
restore-keys: ${{ runner.OS }}-node-
2326
- run: npm ci
2427
- run: npm run build
25-
- run: cd npm && npm publish
28+
- name: 'Determine NPM tag: latest or next depending if we are on a prerelease or not (version with hyphen should be a prerelease)'
29+
id: npm_tag
30+
run: |
31+
VERSION=$(node -p "require('./package.json').version")
32+
if [[ $VERSION == *-* ]]; then
33+
echo "::set-output name=TAG::next"
34+
else
35+
echo "::set-output name=TAG::latest"
36+
fi
37+
- run: cd npm && npm publish --provenance --tag ${{ steps.npm_tag.outputs.TAG }}
2638
env:
2739
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
< 8000 td data-grid-cell-id="diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed-133-135-2" data-line-anchor="diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4edR135" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">

Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Dates are formatted as YYYY-MM-DD.
88

99
## Unreleased
1010

11+
## [5.0.0-beta.6]
12+
1113
- [BREAKING] Remove deprecated methods:
1214

1315
- `Map.of('k', 'v')`: use `Map([ [ 'k', 'v' ] ])` or `Map({ k: 'v' })`
@@ -133,6 +135,10 @@ Map<{ a?: string }>({ a: 'a' }).delete('a'); // you can only delete an optional
133135
134136
For now, only `get`, `getIn`, `set`, `update`, `delete`, `remove`, `toJS`, `toJSON` methods are implemented. All other methods will fallback to the basic `Map` definition. Other method definition will be added later, but as some might be really complex, we prefer the progressive enhancement on the most used functions.
135137

138+
## [4.3.7] - 2024-07-22
139+
140+
- Fix issue with slice negative of filtered sequence [#2006](https://github.com/immutable-js/immutable-js/pull/2006) by [@jdeniau](https://github.com/jdeniau)
141+
136142
## [4.3.6] - 2024-05-13
137143

138144
- Fix `Repeat(<value>).equals(undefined)` incorrectly returning true [#1994](https://github.com/immutable-js/immutable-js/pull/1994) by [@butchler](https://github.com/butchler)

__tests__/Range.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,15 @@ describe('Range', () => {
201201

202202
expect(r).toEqual(200);
203203
});
204+
205+
it('sliced sequence works even on filtered sequence', () => {
206+
expect(Range(0, 3).slice(-2).toArray()).toEqual([1, 2]);
207+
208+
expect(
209+
Range(0, 3)
210+
.filter($ => true)
211+
.slice(-2)
212+
.toArray()
213+
).toEqual([1, 2]);
214+
});
204215
});

src/Operations.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,16 +408,16 @@ export function sliceFactory(collection, begin, end, useKeys) {
408408
return collection;
409409
}
410410

411-
const resolvedBegin = resolveBegin(begin, originalSize);
412-
const resolvedEnd = resolveEnd(end, originalSize);
413-
414-
// begin or end will be NaN if they were provided as negative numbers and
411+
// begin or end can not be resolved if they were pr 855B ovided as negative numbers and
415412
// this collection's size is unknown. In that case, cache first so there is
416413
// a known size and these do not resolve to NaN.
417-
if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
414+
if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) {
418415
return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
419416
}
420417

418+
const resolvedBegin = resolveBegin(begin, originalSize);
419+
const resolvedEnd = resolveEnd(end, originalSize);
420+
421421
// Note: resolvedEnd is undefined when the original sequence's length is
422422
// unknown and this slice did not supply an end and should contain all
423423
// elements after resolvedBegin.

0 commit comments

Comments
 (0)
0