var Promise = require('bluebird');
const levelup = require('level');
const db = Promise.promisifyAll(levelup('./data', {
	valueEncoding: 'json'
}));

module.exports = {
	get: function(id, rev) {
		return db.getAsync(id + ':' + rev)
	},
	revisions: function(id) {
		return db.getAsync(id + ':revisions')
			.then(null, function (err) {
				if (err.notFound) return 0;
				return Promise.reject(err);
			})
	},
	save: function(id, code, version) {
		var rev;
		version = version === 'unstable' ? version : 'stable';
		return this.revisions(id)
			.then(function (revs) {
				rev = ++revs;
				return Promise.all([
					db.putAsync(id + ':revisions', revs),
					Promise.resolve({code: code, version: version})
						.then(db.putAsync.bind(db, id + ':' + revs))
				])
			}).then(function () {
				return {id: id, revision: rev};
			})
	}
};

@@ -657,68 +657,8 @@
 %09%09%09%09
-Promise.resolve(%7Bcode: code, version: version%7D)%0A%09%09%09%09%09%09.then(
 db.p
@@ -668,18 +668,9 @@
 sync
-.bind(db, 
+(
 id +
@@ -680,17 +680,33 @@
 ' + revs
-)
+, %7Bcode, version%7D
 )%0A%09%09%09%09%5D)

Fix weird logic