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
/** Ideally this will be declared in a constants module */ | |
const ADD_PARAGRAPH_DELTA = "addParagraph"; | |
const DELETE_PARAGRAPH_DELTA = "deleteParagraph"; | |
const UPDATE_PARAGRAPH_DELTA = "updateParagraph"; | |
let sectionParagraphIndices = []; | |
/** | |
* @param {string} delta | |
* @param {Array} paragraphs |
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
const wordsToExclude = ['and', 'he', 'the', 'to', 'is', 'Jack', 'Jill'] | |
const literatureText = 'Jack and Jill went to the market to buy bread and cheese. Cheese is Jack\'s and Jill\'s favorite food' | |
const getTokenizedWords = (word) => { | |
if (!word || word === '') return [] | |
return word.split(/\W+/) | |
} | |
const getValidTokenizedWords = (words, excludedWords) => { | |
if (!words || words.length === 0) return [] |
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
{ | |
byId: { | |
'entity-id': { | |
//Any of Class, Subject, Module or any other entity | |
} | |
}, | |
subjects: { | |
byClass: { | |
'class-id-1': ['class-id-1-subject-id-1', 'class-id-1-subject-id-2',...], | |
'class-id-2': ['class-id-2-subject-id-1', 'class-id-2-subject-id-2',...], |
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
[ | |
{ | |
id: 'class-1', | |
subjects: [ | |
{ | |
id: 'subject-1-class-1', | |
modules: [ | |
{ | |
id: 'module-1-subject-1-class-1', | |
... |
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
const findWordsInBoard = (board, listOfWords) => { | |
/* Returns a subset of words in listOfWords | |
* that can be formed from characters on board | |
*/ | |
}; | |
const BOARD = [ | |
['g','r','t','a'], | |
['n','i','a','e'], | |
['d','k','w','r'], | |
['t','e','l','v'] |
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
const findMinTimeDiff = (listOfTimes) => { | |
/** Returns the minimum time difference in minutes between any two points **/ | |
} | |
findMinTimeDiff(['00:00', '00:01']); //should return 1 minute | |
findMinTimeDiff(['00:03', '03:12', '00:00', '03:14']); //should return 2 minutes | |
findMinTimeDiff(['13:20', '00:01', '14:00', '18:05', '13:28']); //should return 8 minutes | |
findMinTimeDiff(['00:00', '00:02', '23:59', '00:05']); //should return 1 minute |
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
const isCat = (animal: Animal): animal is Cat => { | |
//Hey compiler, this animal is a Cat | |
return true; | |
} |
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
const isCat = (animal: Animal):boolean => { | |
return (animal as Cat).meow | |
} | |
const isDog = (animal: Animal): boolean => { | |
return (animal as Dog).bark | |
} |
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
interface Cat { | |
meow(); | |
walk(); | |
} | |
interface Dog { | |
bark(); | |
walk(); | |
} |
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
const isPresentObject = <T>(arg: T): arg is T => { | |
if (arg && Object.keys(arg).length > 0) { | |
return true; | |
} | |
return false; | |
} |
NewerOlder