Skip to content

Commit 72729f4

Browse files
committed
dropped dependency + updated bundling
1 parent 1ba4c7a commit 72729f4

File tree

8 files changed

+370
-431
lines changed

8 files changed

+370
-431
lines changed

babel-plugins.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

cjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type":"commonjs"}

cjs/utils.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
'use strict';
2-
const Map = (require('@ungap/essential-map'));
3-
42
const {indexOf: iOF} = [];
53
const append = (get, parent, children, start, end, before) => {
64
const isSelect = 'selectedIndex' in parent;
@@ -122,13 +120,12 @@ const HS = (
122120
for (let i = 1; i < minLen; i++)
123121
tresh[i] = currentEnd;
124122

125-
const keymap = new Map;
126-
for (let i = currentStart; i < currentEnd; i++)
127-
keymap.set(currentNodes[i], i);
123+
const nodes = currentNodes.slice(currentStart, currentEnd);
128124

129125
for (let i = futureStart; i < futureEnd; i++) {
130-
const idxInOld = keymap.get(futureNodes[i]);
131-
if (idxInOld != null) {
126+
const index = nodes.indexOf(futureNodes[i]);
127+
if (-1 < index) {
128+
const idxInOld = index + currentStart;
132129
k = findK(tresh, minLen, idxInOld);
133130
/* istanbul ignore else */
134131
if (-1 < k) {
@@ -269,7 +266,7 @@ const applyDiff = (
269266
currentLength,
270267
before
271268
) => {
272-
const live = new Map;
269+
const live = [];
273270
const length = diff.length;
274271
let currentIndex = currentStart;
275272
let i = 0;
@@ -281,7 +278,7 @@ const applyDiff = (
281278
break;
282279
case INSERTION:
283280
// TODO: bulk appends for sequential nodes
284-
live.set(futureNodes[futureStart], 1);
281+
live.push(futureNodes[futureStart]);
285282
append(
286283
get,
287284
parentNode,
@@ -306,7 +303,7 @@ const applyDiff = (
306303
break;
307304
case DELETION:
308305
// TODO: bulk removes for sequential nodes
309-
if (live.has(currentNodes[currentStart]))
306+
if (-1 < live.indexOf(currentNodes[currentStart]))
310307
currentStart++;
311308
else
312309
remove(

esm/utils.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Map from '@ungap/essential-map';
2-
31
const {indexOf: iOF} = [];
42
export const append = (get, parent, children, start, end, before) => {
53
const isSelect = 'selectedIndex' in parent;
@@ -114,13 +112,12 @@ const HS = (
114112
for (let i = 1; i < minLen; i++)
115113
tresh[i] = currentEnd;
116114

117-
const keymap = new Map;
118-
for (let i = currentStart; i < currentEnd; i++)
119-
keymap.set(currentNodes[i], i);
115+
const nodes = currentNodes.slice(currentStart, currentEnd);
120116

121117
for (let i = futureStart; i < futureEnd; i++) {
122-
const idxInOld = keymap.get(futureNodes[i]);
123-
if (idxInOld != null) {
118+
const index = nodes.indexOf(futureNodes[i]);
119+
if (-1 < index) {
120+
const idxInOld = index + currentStart;
124121
k = findK(tresh, minLen, idxInOld);
125122
/* istanbul ignore else */
126123
if (-1 < k) {
@@ -261,7 +258,7 @@ const applyDiff = (
261258
currentLength,
262259
before
263260
) => {
264-
const live = new Map;
261+
const live = [];
265262
const length = diff.length;
266263
let currentIndex = currentStart;
267264
let i = 0;
@@ -273,7 +270,7 @@ const applyDiff = (
273270
break;
274271
case INSERTION:
275272
// TODO: bulk appends for sequential nodes
276-
live.set(futureNodes[futureStart], 1);
273+
live.push(futureNodes[futureStart]);
277274
append(
278275
get,
279276
parentNode,
@@ -298,7 +295,7 @@ const applyDiff = (
298295
break;
299296
case DELETION:
300297
// TODO: bulk removes for sequential nodes
301-
if (live.has(currentNodes[currentStart]))
298+
if (-1 < live.indexOf(currentNodes[currentStart]))
302299
currentStart++;
303300
else
304301
remove(

0 commit comments

Comments
 (0)