Skip to content

Instantly share code, notes, and snippets.

function flatten(arr){
if (!Array.isArray(arr)){
return [arr];
}
return arr.reduce((flat, toFlatten) => {
return flat.concat(flatten(toFlatten));
}, []);
}
function test(objUnderTest){
@evanlarsen
evanlarsen / Mapping.cs
Created January 6, 2014 22:37
Experimenting with Fluent Interface and Generics
using CQRS01.Domain.Entities;
using CQRS01.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace CQRS01.Web.Framework.Mapping
{
public class Test
{
@evanlarsen
evanlarsen / transitionHelper.js
Last active February 8, 2021 17:12
Durandal transition helper file. This imposes that you are using https://github.com/daneden/animate.css Also, that you have changed the animation duration in animate.css from 1s to .3s
define(function(require) {
var system = require('../system');
var animationTypes = [
'bounce',
'bounceIn',
'bounceInDown',
'bounceInLeft',
'bounceInRight',
'bounceInUp',
@evanlarsen
evanlarsen / durandal.d.ts
Last active December 10, 2015 18:09
Durandal module declarations for Typescript
/// <reference path="../../libs/jquery/jquery.d.ts" />
/// <reference path="../../libs/knockout/knockout.d.ts" />
declare module "durandal/system" {
export var getModuleId: (obj: any) => string;
export var debug: (debug?: bool) => bool;
export var isArray: (obj: any) => bool;
export var log: (...msgs: any[]) => void;
export var defer: (action?: Function) => JQueryDeferred;
export var guid: () => string;