(stack, converter, value, key, keyPath, parentValue)
| 18 | } |
| 19 | |
| 20 | function fromJSWith(stack, converter, value, key, keyPath, parentValue) { |
| 21 | if ( |
| 22 | typeof value !== 'string' && |
| 23 | !isImmutable(value) && |
| 24 | (isArrayLike(value) || hasIterator(value) || isPlainObj(value)) |
| 25 | ) { |
| 26 | if (~stack.indexOf(value)) { |
| 27 | throw new TypeError('Cannot convert circular structure to Immutable'); |
| 28 | } |
| 29 | stack.push(value); |
| 30 | // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here |
| 31 | keyPath && key !== '' && keyPath.push(key); |
| 32 | const converted = converter.call( |
| 33 | parentValue, |
| 34 | key, |
| 35 | Seq(value).map((v, k) => |
| 36 | fromJSWith(stack, converter, v, k, keyPath, value) |
| 37 | ), |
| 38 | keyPath && keyPath.slice() |
| 39 | ); |
| 40 | stack.pop(); |
| 41 | // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here |
| 42 | keyPath && keyPath.pop(); |
| 43 | return converted; |
| 44 | } |
| 45 | return value; |
| 46 | } |
| 47 | |
| 48 | function defaultConverter(k, v) { |
| 49 | // Effectively the opposite of "Collection.toSeq()" |
no test coverage detected