Skip to content

Instantly share code, notes, and snippets.

@gblok
Last active October 12, 2017 06:17
Show Gist options
  • Save gblok/d5447a1ad820bcaf5eaf95d9dc80646f to your computer and use it in GitHub Desktop.
Save gblok/d5447a1ad820bcaf5eaf95d9dc80646f to your computer and use it in GitHub Desktop.
import Gun from 'gun/gun'
localStorage.clear()
const guid = () => [2,1,1,1,3].map(n => Array.from(Array(n), () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)).join('')).join('-')
const gun = new Gun
const notes = gun.get('notes')
notes.map().on((id, name) => console.log('ls', id, name))
function AddItem(key) {
let id = guid()
notes.get(id).put({key, id})
}
Array.from(Array(5).keys()).filter(Boolean).forEach(AddItem)
///map().on() why return multi one item entry?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment