Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🦄 Hackin'

Beau beaucharman

💭
🦄 Hackin'
View GitHub Profile
View Portal_Teams.addTeamMember.request.js
// Portal_Teams.addTeamMember.request.js
{
...
data: {
ClassName: 'Platform_Teams',
MethodName: 'addTeamMember',
Parameter: {
name: 'Name',
practitionerId: '0050k000000FtmGAAS',
clients: [ // Group and all it's entities
@beaucharman
beaucharman / deepArrayMerge.js
Last active Aug 15, 2017
deepArrayMerge.js
View deepArrayMerge.js
// const { unionBy, isArray, merge, find } = _
const deepArrayMerge = (initial, replacement, key) => unionBy(initial, replacement, key)
.map(item => merge({}, item, find(isArray(replacement) ? replacement : [replacement], { [key]: item[key] })))
@beaucharman
beaucharman / example.js
Last active Feb 4, 2019
A conditional higher order function
View example.js
unless(booleanExpression, () => {
// Then callback
})
@beaucharman
beaucharman / compose.js
Last active Jan 19, 2017
Returns a function that composes a series of methods together, passing the return value of each from left to right (First method can take multiple arguments)
View compose.js
const compose = (...functions) => (...start) => (
functions.reduce((result, f) => (
(typeof result === 'object') ? f(...result) : f(result)
), start)
)
/**
* Usage
@beaucharman
beaucharman / throttle.js
Last active Jul 15, 2020
An ES6 implementation of the throttle function. "Throttling enforces a maximum number of times a function can be called over time. As in 'execute this function at most once every 100 milliseconds.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debouncing/)
View throttle.js
function throttle(callback, wait, immediate = false) {
let timeout = null
let initialCall = true
return function() {
const callNow = immediate && initialCall
const next = () => {
callback.apply(this, arguments)
timeout = null
}
@beaucharman
beaucharman / git-rebase.notes.md
Last active Nov 1, 2017
Notes: Git rebase process
View git-rebase.notes.md
  1. git checkout <master>
  2. git merge origin <master>
  3. git checkout <feature>
  4. git rebase <master>
  5. deal with any conflicts
  6. git add .
  7. git rebase --continue
  8. git push origin <feature> --force
  9. 😎
@beaucharman
beaucharman / revive.js
Last active Jun 22, 2016
Revive.js; A simple implementation of the awesome http://redux.js.org/
View revive.js
const Revived = () => {
createStore = (reducer) => {
let state
let listeners = []
const getState = () => state
const dispatch = (action) => {
state = reducer(state, action)
@beaucharman
beaucharman / debounce.js
Last active Sep 11, 2020
An ES6 implementation of the debounce function. "Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in 'execute this function only if 100 milliseconds have passed without it being called.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debounc…
View debounce.js
function debounce(callback, wait, immediate = false) {
let timeout = null
return function() {
const callNow = immediate && !timeout
const next = () => callback.apply(this, arguments)
clearTimeout(timeout)
timeout = setTimeout(next, wait)
@beaucharman
beaucharman / pureSplice.js
Last active Feb 22, 2019
An ES6 / pure function implementation of the JS splice method that returns an object of the new array and the removed elements
View pureSplice.js
function safeSplice(array, start, deleteCount, ...replace) {
const removed = array.splice(start, deleteCount, ...replace)
return {
array: array,
removed: removed,
}
}
/** usage
const array = [1, 2, 3, 4, 5, 6]
@beaucharman
beaucharman / reactLifecycleMethods.notes.md
Last active Mar 15, 2019
Notes: A cheat sheet for the React Component Lifecycle Methods
View reactLifecycleMethods.notes.md

Mounting

componentWillMount
componentWillMount()
  • setState() can be called here and won't cause a rerender

You can’t perform that action at this time.