const compose = (...fns) =>
fns.reduceRight((prevFn, nextFn) =>
(...args) => nextFn(prevFn(...args)),
value => value
);
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
((context) => { | |
// Create the namespace if it's not created yet. | |
if(!context.PESTICIDE) context.PESTICIDE = {isDebugging: false}; | |
// Color table (tag name and hexadecimal value). | |
var COLOR_TABLE = { | |
'body': '#2980b9', | |
'article': '#3498db', | |
'nav': '#0088c3', |
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 { useReducer } from 'react' | |
export function updateName(name: string) { | |
return <const>{ | |
type: 'UPDATE_NAME', | |
name | |
} | |
} | |
export function addPoints(points: number) { |
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
/* Calculate whether a LIC is trading at a Premium or Discount */ | |
function calcNtaDiscountPercentage( | |
lastAsx200: number, | |
currentAsx200: number, | |
lastNta: number, | |
currentPrice: number | |
) { | |
const estimatedNta = (currentAsx200 / lastAsx200) * lastNta; | |
const result = (estimatedNta - currentPrice) / estimatedNta; | |
return +(result * 100).toFixed(3); |
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 _ from 'lodash'; | |
/** | |
* Deep diff between two objects - i.e. an object with the new value of new & changed fields. | |
* Removed fields will be set as undefined on the result. | |
* Only plain objects will be deeply compared (@see _.isPlainObject) | |
* | |
* Inspired by: https://gist.github.com/Yimiprod/7ee176597fef230d1451#gistcomment-2565071 | |
* This fork: https://gist.github.com/TeNNoX/5125ab5770ba287012316dd62231b764/ | |
* |
OlderNewer