Skip to content

Instantly share code, notes, and snippets.

View iofjuupasli's full-sized avatar

Valery iofjuupasli

  • fugo.ai
  • Warsaw, Poland
  • 23:26 (UTC +02:00)
View GitHub Profile
/*jslint nomen: true, vars: true*/
/*global define*/
define(['jquery', 'lodash'], function ($, _) {
'use strict';
var FallbackCrud = (function () {
function Class() {
this.cruds = arguments;
}
_.forEach(['create', 'read', 'update', 'del'], function (method) {
@iofjuupasli
iofjuupasli / manyToManyMap.js
Last active August 29, 2015 13:57
Mapping array of many-to-many entities to map with faster access
function manyToManyMap(source, first, second) {
'use strict';
var result = {}, i, item;
for (i = 0; i < source.length; i += 1) {
item = source[i];
if (!result[item[first]]) {
result[item[first]] = {};
}
result[item[first]][item[second]] = item;
}