8000 Testing PR integration by andrejcesen · Pull Request #1 · andrejcesen/immutable-js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Testing PR integration #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d219218
Fix List.removeAfter() bug
Oct 27, 2024
5f0de66
Merge pull request #2033 from immutable-js/release-5.0.0
jdeniau Nov 3, 2024
1bac556
chore: upgrade TSTyche
mrazauskas Nov 4, 2024
0466baa
Merge pull request #2034 from mrazauskas/upgrade-tstyche
jdeniau Nov 4, 2024
7452d39
create single dist esm file to clear circular dependencies
bumblehead Sep 24, 2024
12834a7
Merge branch 'iambumblehead-generate-dist-esm-file-to-clear-circular-…
jdeniau Nov 7, 2024
52c3c64
5.0.1
jdeniau Nov 7, 2024
4413273
handle the fact that bundlephobia might be down
jdeniau Nov 8, 2024
a2e2f96
fix path to es version
jdeniau Nov 8, 2024
879f428
5.0.2
jdeniau Nov 8, 2024
c89ec4c
fix: VNode.removeBefore & removeAfter bugs
Nov 9, 2024
60fce4f
add test on the first 2000 integer
jdeniau Nov 19, 2024
9548738
Merge pull request #2030 from alexvictoor/remove-after-bug
jdeniau Nov 19, 2024
a913952
5.0.3
jdeniau Nov 19, 2024
b3a1c9f
Merge pull request #2036 from immutable-js/release-5.0.3
jdeniau Nov 19, 2024
61d90ab
fix: non recursive implementation of concat
Dec 9, 2024
cc87630
fix: proper Typescript typings for Seq.concat()
Dec 9, 2024
65b0f48
Merge pull request #2038 from alexvictoor/fix-issue-1915
jdeniau Jan 11, 2025
1057b93
Update CHANGELOG.md
jdeniau Jan 11, 2025
a2bc1b4
Merge pull request #2040 from alexvictoor/fix-seq-typings
jdeniau Jan 11, 2025
2127c62
Update CHANGELOG.md
jdeniau Jan 11, 2025
7b615ff
test Seq.concat typing
jdeniau Jan 11, 2025
aa51198
Merge pull request #2042 from immutable-js/test-seq-concat-typing
jdeniau Jan 11, 2025
4f8dbce
Testing PR integration
andrejcesen Mar 20, 2025
9d0ddf2
Testing PR integration2
andrejcesen Mar 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10000
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ Dates are formatted as YYYY-MM-DD.

## Unreleased

- Fix #1915 "Converting a Seq to a list causes RangeError (max call size exceeded)" by @alexvictoor in [#2038](https://github.com/immutable-js/immutable-js/pull/2038)
- fix: proper Typescript typings for Seq.concat() [#2040](https://github.com/immutable-js/immutable-js/pull/2040) by [@alexvictoor](https://github.com/alexvictoor)

## [5.0.3]

- Fix List.VNode.removeAfter() / removeBefore() issue on some particular case [#2030](https://github.com/immutable-js/immutable-js/pull/2030) by [@alexvictoor](https://github.com/alexvictoor)

## [5.0.2]

- Fix wrong path for esm module after fix in 5.0.1

## [5.0.1]

- Fix circular dependency issue with ESM build by @iambumblehead in [#2035](https://github.com/immutable-js/immutable-js/pull/2035) by [@iambumblehead](https://github.com/iambumblehead)

## [5.0.0]

### Breaking changes
Expand Down
27 changes: 27 additions & 0 deletions __tests__/List.ts
8000
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,33 @@ describe('List', () => {
expect(o.get(0)).toBe('f');
});

it('works with push, set and insert without phantom values', () => {
const v = List.of().set(287, 287).push(42).insert(33, 33);
expect(v.toJS().filter(item => item === 287)).toHaveLength(1);
const v2 = List.of().push(0).unshift(-1).unshift(-2).pop().pop().set(2, 2);
expect(v2.toJS()).toEqual([-2, undefined, 2]);
const v3 = List.of().set(447, 447).push(0).insert(65, 65);
expect(v3.toJS().filter(item => item === 447)).toHaveLength(1);
const v4 = List.of().set(-28, -28).push(0).shift().set(-30, -30);
expect(v4.toJS().filter(item => item === -28)).toHaveLength(0);
const v5 = List.of().unshift(0).set(33, 33).shift().set(-35, -35);
expect(v5.toJS().filter(item => item === 0)).toHaveLength(0);

// execute the same test as `v` but for the 2000 first integers
const isOkV1 = v =>
List.of()
.set(v, v)
.push('pushed-value')
.insert(33, 'inserted-value')
.filter(item => item === v).size === 1;

const arr = new Array(2000).fill(null).map((_, v) => v);

const notOkArray = arr.filter(v => !isOkV1(v));

expect(notOkArray).toHaveLength(0);
});

// TODO: assert that findIndex only calls the function as much as it needs to.

it('forEach iterates in the correct order', () => {
Expand Down
41 changes: 39 additions & 2 deletions __tests__/concat.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { is, List, Seq, Set } from 'immutable';
import { List, Seq, Set } from 'immutable';

describe('concat', () => {
it('concats two sequences', () => {
const a = Seq([1, 2, 3]);
const b = Seq([4, 5, 6]);
expect(is(a.concat(b), Seq([1, 2, 3, 4, 5, 6]))).toBe(true);
expect(a.concat(b).size).toBe(6);
expect(a.concat(b).toArray()).toEqual([1, 2, 3, 4, 5, 6]);
});
Expand Down Expand Up @@ -181,4 +180,42 @@ describe('concat', () => {
expect(i.get(-4)).toBe(-9);
expect(i.get(-5, 888)).toBe(888);
});

it('should iterate on many concatenated sequences', () => {
let meta = Seq();

for (let i = 0; i < 10000; ++i) {
meta = meta.concat(i) as Seq<unknown, unknown>; // TODO fix typing
}

expect(meta.toList().size).toBe(10000);
});

it('should handle iterator on many concatenated sequences', () => {
const nbLoops = 10000;
let meta = Seq();
for (let i = 1; i < nbLoops; i++) {
meta = meta.concat(i) as Seq<unknown, unknown>; // TODO fix typing
}
const it = meta[Symbol.iterator]();
let done = false;
let i = 0;
while (!done) {
const result = it.next();
i++;
done = !!result.done;
}
expect(i).toBe(nbLoops);
});

it('should iterate on reverse order on concatenated sequences', () => {
let meta = Seq([1]);
meta = meta.concat(42);
const it = meta.reverse()[Symbol.iterator]();
const result = it.next();
expect(result).toEqual({
done: false,
value: 42,
});
});
});
21 changes: 11 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "immutable",
"version": "5.0.0",
"version": "5.0.3",
"description": "Immutable Data Collections",
"license": "MIT",
"homepage": "https://immutable-js.com",
Expand All @@ -16,7 +16,7 @@
"url": "https://github.com/immutable-js/immutable-js/issues"
},
"main": "dist/immutable.js",
"module": "dist/es/Immutable.js",
"module": "dist/immutable.es.js",
"types": "dist/immutable.d.ts",
"files": [
"dist",
Expand Down Expand Up @@ -60,8 +60,8 @@
"test:types": "tstyche",
"format": "npm run lint:format -- --write",
"lint": "run-s lint:*",
"lint:format": "prettier --check \"{__tests__,src,type-definitions,website/src,perf,resources}/**/*{.js,.ts,.tsx,.flow,.css}\"",
"lint:js": "eslint \"{__tests__,src,type-definitions,website/src}/**/*.{js,ts,tsx}\"",
"lint:format": "prettier --check \"{__tests__,src,type-definitions,website/src,perf,resources}/**/*{.js,.mjs,.ts,.tsx,.flow,.css}\"",
"lint:js": "eslint \"{__tests__,src,type-definitions,website/src}/**/*.{js,mjs,ts,tsx}\"",
"type-check": "run-s type-check:*",
"type-check:ts": "tsc --project type-definitions/tsconfig.json && tsc --project __tests__/tsconfig.json",
"type-check:flow": "flow check type-definitions/flow-tests --include-warnings",
Expand Down Expand Up @@ -127,25 +127,25 @@
"rollup": "3.28.1",
"size-limit": "^8.2.6",
"transducers-js": "0.4.174",
"tstyche": "^2.1.1",
"tstyche": "^3.0.0-rc.2",
"typescript": "5.1"
},
"size-limit": [
{
"name": "all",
"path": "dist/es/Immutable.js",
"path": "dist/immutable.es.js",
"import": "*",
"limit": "20 kB"
},
{
"name": "List",
"path": "dist/es/Immutable.js",
"path": "dist/immutable.es.js",
"import": "{ List }",
"limit": "20 kB"
},
{
"name": "Seq",
"path": "dist/es/Immutable.js",
"path": "dist/immutable.es.js",
"import": "{ Seq }",
"limit": "20 kB"
}
Expand Down
37 changes: 20 additions & 17 deletions resources/dist-stats.mjs
10000
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ async function bundlephobaInfo(key) {
`https://bundlephobia.com/api/size?package=immutable@${VERIFY_AGAINST_VERSION}`
);

console.log(res.status);

if (res.status !== 200) {
throw new Error(
`Unable to fetch bundlephobia in dist-stats.mjs. Status code is "${res.status}"`
Expand All @@ -50,7 +48,7 @@ async function bundlephobaInfo(key) {
return bundlephobaInfoCache[key];
}

Promise.all([
Promise.allSettled([
fs.readFile('dist/immutable.js'),
fs.readFile('dist/immutable.min.js'),
bundlephobaInfo('size'),
Expand All @@ -59,23 +57,28 @@ Promise.all([
])
.then(results =>
results.map(result =>
typeof result === 'number'
typeof (result === null || result === 'number')
? result
: Number(Buffer.byteLength(result, 'utf8'))
)
)
.then(([rawNew, minNew, minOld, zipNew, zipOld]) => {
console.log(` Raw: ${space(14, bytes(rawNew).cyan)}`);
console.log(
` Min: ${space(14, bytes(minNew).cyan)}${percentage(
minNew,
rawNew
)}${space(15, diff(minNew, minOld))}`
);
console.log(
` Zip: ${space(14, bytes(zipNew).cyan)}${percentage(
zipNew,
rawNew
)}${space(15, diff(zipNew, zipOld))}`
);
console.log(` Raw: ${space(14, bytes(rawNew.value).cyan)}`);
if (minOld.status === 'fulfilled') {
console.log(
` Min: ${space(14, bytes(minNew.value).cyan)}${percentage(
minNew.value,
rawNew.value
)}${space(15, diff(minNew.value, minOld.value))}`
);
}

if (zipOld.status === 'fulfilled') {
console.log(
` Zip: ${space(14, bytes(zipNew.value).cyan)}${percentage(
zipNew.value,
rawNew.value
)}${space(15, diff(zipNew.value, zipOld.value))}`
);
}
});
4 changes: 1 addition & 3 deletions resources/rollup-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ export default [
{
banner: copyright,
name: 'Immutable',
dir: path.join(DIST_DIR, 'es'),
file: path.join(DIST_DIR, 'immutable.es.js'),
format: 'es',
preserveModules: true,
preserveModulesRoot: SRC_DIR,
sourcemap: false,
},
],
Expand Down
3 changes: 2 additions & 1 deletion src/Iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Iterator.prototype[ITERATOR_SYMBOL] = function () {
};

export function iteratorValue(type, k, v, iteratorResult) {
const value = type === 0 ? k : type === 1 ? v : [k, v];
const value =
type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v];
iteratorResult
? (iteratorResult.value = value)
: (iteratorResult = {
Expand Down
10 changes: 8 additions & 2 deletions 10 src/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ class VNode {
// TODO: seems like these methods are very similar

removeBefore(ownerID, level, index) {
if (index === level ? 1 << level : 0 || this.array.length === 0) {
if (
(index & ((1 << (level + SHIFT)) - 1)) === 0 ||
this.array.length === 0
) {
return this;
}
const originIndex = (index >>> level) & MASK;
Expand Down Expand Up @@ -304,7 +307,10 @@ class VNode {
}

removeAfter(ownerID, level, index) {
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
if (
index === (level ? 1 << (level + SHIFT) : SIZE) ||
this.array.length === 0
) {
return this;
}
const sizeIndex = ((index - 1) >>> level) & MASK;
Expand Down
Loading
0