This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ErrorController } from './types'; | |
function throwIfConditionIsTrue(error: Error | string, condition: boolean): void { | |
if (condition) throw error instanceof Error ? error : new Error(error); | |
} | |
export function throwError(error: Error | string): ErrorController { | |
const when = { | |
isNull: (arg: unknown): void => throwIfConditionIsTrue(error, arg === null), | |
isUndefined: (arg: unknown): void => throwIfConditionIsTrue(error, typeof arg === 'undefined'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function render(...args: Array<any>) { | |
const strings = args[0]; | |
const params = args.slice(1); | |
const results = await Promise.allSettled(params.map(param => typeof param === 'function' ? param() : param)); | |
return strings.map((str: string, i: number): string => { | |
const result = results[i]; | |
if (result == null) return str; | |
return str + (result.status === 'fulfilled' ? result.value : result.reason); | |
}).join(''); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { JSX } from 'solid-js'; | |
import { CounterContextProvider, useCounterContext } from '../contexts/counter'; | |
export function WithContext(): JSX.Element { | |
const [ { count }, { increment, decrement } ] = useCounterContext(); | |
return ( | |
<CounterContextProvider> | |
<span>{count}</span> | |
<button onClick={increment}>+</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class PubSub { | |
constructor() { | |
this._subs = new Map() | |
} | |
subscribe(action, fn) { | |
if (!this._subs.has(action)) { | |
this._subs.set(action, new Set()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @class | |
* @classdesc The Job model class | |
*/ | |
var Job = Model.extend({ | |
idAttribute: 'resource_uri', | |
defaults: { | |
name: 'n/a' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Sibling() { | |
mediator.add(this); | |
this.id = Sibling.getUniqueID(); | |
} | |
Sibling.getUniqueID = (function () { | |
var id = 0; | |
return function () { | |
return id++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Provides basic Pub/Sub interface and functionality | |
* | |
* @class Observable | |
*/ | |
function Observable() { | |
this.subscribers = []; | |
} | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://pastebin.com/zKpJY9ck - copy from there | |
# single line comment | |
## | |
multi line comment | |
## | |
# variable assignment | |
a = 7. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Backbone.js 2.0.0 | |
// (c) 2010-2011 Jeremy Ashkenas, DocumentCloud Inc. | |
// (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | |
// Backbone may be freely distributed under the MIT license. | |
// For all details and documentation: | |
// http://backbonejs.org | |
(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var prototypeTest = (function () { | |
/** | |
* Instance class definition | |
* inherits from Base | |
*/ | |
function Instance() { | |
//super class constructor | |
Base.apply(this, arguments); | |
} | |
NewerOlder