Skip to content

Instantly share code, notes, and snippets.

@freshsun
freshsun / json2es6maps.js
Created November 14, 2017 08:44 — forked from matthewmorrone/json2es6maps.js
Converting ES6 Maps to and from JSON
function mapToJson(map) {
return JSON.stringify([...map]);
}
function jsonToMap(jsonStr) {
return new Map(JSON.parse(jsonStr));
}
function strMapToObj(strMap) {
let obj = Object.create(null);
for (let [k,v] of strMap) {
// We don’t escape the key '__proto__'
@freshsun
freshsun / test.js
Last active August 29, 2015 14:06 — forked from bendrucker/test.js
var knex = require('knex')({
client: 'postgres',
connection: {
database: "bookshelf_487"
}
});
var bookshelf = require('bookshelf')(knex);
var Model = bookshelf.Model.extend({
tableName: 'test_table'
});