Last active
July 14, 2017 01:07
-
-
Save zaaack/4270c23dcbeef305b236ae3c930db213 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Struct } from 'immuter' | |
const struct = Struct({ | |
title: { | |
zh: '哈利·波特与魔法石', | |
en: 'Harry Potter and the Philosopher\'s Stone', | |
}, | |
author: 'J. k. rowling', | |
tags: ['novel', 'magic'], | |
}) | |
const struct1 = Struct.clone(struct) // Copy struct, but only modified part will change | |
struct1.author = 'New Author' | |
struct1.title.en = 'New Title' | |
struct1 === struct // false | |
struct1.author === struct.author // false | |
struct1.title === struct.title // false | |
struct1.tags === struct.tags // true | |
Struct.isStruct(struct) // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment