Every mode (src/index.js, src/full.js, src/lite.js, src/json.js) picked its clone strategy from Object.prototype.toString.call(x), which reads a user-settable Symbol.toStringTag. A plain object declaring a recognized tag (eg "Map") was routed into that type's clone branch and crashed on methods it doesn't have; one with an unrecognized tag fell through every branch and was returned by reference instead of cloned. Also check the object's real constructor, which Symbol.toStringTag cannot affect, so a plain object (or one with no prototype) is still deep-cloned as a plain object no matter what tag it claims. Fixes #54
26 lines
448 B
JavaScript
26 lines
448 B
JavaScript
import * as suites from './suites';
|
|
import { klona } from '../src/index';
|
|
|
|
suites.API(klona);
|
|
|
|
suites.Strings(klona);
|
|
suites.Booleans(klona);
|
|
suites.Numbers(klona);
|
|
suites.Nully(klona);
|
|
|
|
suites.Dates(klona);
|
|
suites.RegExps(klona);
|
|
|
|
suites.Objects(klona);
|
|
suites.Arrays(klona);
|
|
suites.ToStringTag(klona);
|
|
|
|
suites.Functions(klona);
|
|
suites.Pollutions(klona);
|
|
suites.Classes(klona);
|
|
|
|
suites.Maps(klona);
|
|
suites.Sets(klona);
|
|
|
|
suites.TypedArrays(klona);
|