const TRUNCATE_WORDS_CUTOFF = 12;
export const truncateName = (name: string, truncateCutoff: number = TRUNCATE_WORDS_CUTOFF) =>
name.length > truncateCutoff
? `${name.substring(0, truncateCutoff)}...`
: name;
The visualization component takes as inputs
matrix
- A N x M matrix where N is the number of columns and M is the number of rows. Each element of the matrix specifies the i of building block to render.workflowVisData
- A datastructure that represents the graph of all the workflow steps with information on how they are connected and the distance between the node and the root of the graph (assumed to be a directed acyclic graph (DAG)).
matrix
is created from workflowVisData
as follows:
- Initialize a N x M
matrix
. N is longest path in the DAG (workflowStepOrder
is pre-calculated for each node in the graph which provides the path of the node from the root node). M is calculated from the largest frequency ofworkflowStepOrder
.matrix
is initialized withempty
.
- The State of TypeScript in 2019 by Jason Killian
- Intro to TypeScript by Dan Vanderkam
- Strong Strings by Jason Killian
- Shipping TypeScript to NPM by Steve Faulkner
- End-to-end Type safe GraphQL Apps with Typescript by Carlos Rufo
- Building Custom TSLint Rules by Ash Furrow
- Type Variance & Type Safety in React Prop Injection by Scott Cheng
- Referential Transparency by Dan Vanderkam
This file contains hidden or 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
package main | |
import ( | |
"math/rand" | |
"os" | |
svg "github.com/ajstarks/svgo" | |
) | |
var ( |
This file contains hidden or 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 React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { CompositeDecorator, convertFromRaw, Editor, EditorState } from 'draft-js'; | |
// Following code based on: | |
// https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/link/link.html | |
const Link = (props) => { | |
const {url} = props.contentState.getEntity(props.entityKey).getData(); | |
return ( | |
<a rel="nofollow noreferrer" href={url} target="_blank"> |
This file contains hidden or 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 React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { | |
convertToRaw, | |
EditorState, | |
RichUtils | |
} from 'draft-js'; | |
import Editor from 'draft-js-plugins-editor'; | |
import createMarkdownPlugin from 'draft-js-markdown-plugin'; | |
import createInlineToolbarPlugin, { Separator } from 'draft-js-inline-toolbar-plugin'; |
This file contains hidden or 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
const test = (fun testCases) => { | |
testCases.map(t => { | |
const shouldBe = t.shouldBe; | |
const is = fun(t.test); | |
const res = (shouldBe === is) ? 'passed' : 'failed'; | |
const moreInfo = (res === 'failed') ? `testing ${t.test}. Should be ${shouldBe} but got ${is}` : '' | |
console.log(`${res} ${moreInfo}`); | |
}) | |
} |
This file contains hidden or 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
let testCases = [ | |
{test: '(', shouldBe: false}, | |
{test: '())', shouldBe: false}, | |
{test: null, shouldBe: false}, | |
{test: undefined, shouldBe: false}, | |
{test: 22, shouldBe: false}, | |
{test: ')(', shouldBe: false}, | |
{test: '', shouldBe: true}, | |
{test: '()', shouldBe: true}, | |
{test: '()()', shouldBe: true}, |
This file contains hidden or 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
// Parentheses Tally | |
const newOpenCnt = (c, openCnt) => { | |
if (c === '(') return openCnt + 1 | |
if (c === ')') return openCnt - 1 | |
return openCnt | |
} | |
function isBalanced(str, openCnt) { | |
// Continue or Stop? | |
if (typeof str !== 'string') return false |
This file contains hidden or 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
// shared/components/HTML.js | |
import React from 'react'; | |
const HTML = (props) => ( | |
<html lang="en"> | |
<head> | |
<title>Isomorphic Router Demo</title> | |
<link | |
rel="stylesheet" |