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 Ember from 'ember'; | |
export function inlineStyle(params, hash) { | |
let strInnerStyle = ''; | |
for (let key in hash) { | |
if (hash.hasOwnProperty(key)) { | |
hash[key] = (key === 'background-image') ? `url(${hash[key]})` : `${hash[key]}`; | |
strInnerStyle += `${key}: ${hash[key]}; `; |
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 Ember from 'ember'; | |
export function logJson(params/*, hash*/) { | |
console.log(params[0].toJSON()); | |
} | |
export default Ember.Helper.helper(logJson); |
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 Ember from 'ember'; | |
export function math([numOperand1, strOperator, numOperand2]/*, hash*/) { | |
numOperand1 = parseFloat(numOperand1); | |
numOperand2 = parseFloat(numOperand2); | |
return { | |
'+': numOperand1 + numOperand2, | |
'-': numOperand1 - numOperand2, | |
'*': numOperand1 * numOperand2, |
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 Ember from 'ember'; | |
export function range(params/*, hash*/) { | |
var arrRange = []; | |
for (var i = params[0]; i <= params[1]; i++) { | |
arrRange.push(i); | |
} | |
return arrRange; |
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 Ember from 'ember'; | |
export function roundNumber(params/*, hash*/) { | |
return parseInt(params[0]).toFixed(params[1] || 0); | |
} | |
export default Ember.Helper.helper(roundNumber); |
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
body { | |
background-color: #faf4f1; | |
} | |
form { | |
margin-top: 1rem; | |
} | |
dt { | |
color: #999; |
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 generateHash() { | |
let intHash = 0, | |
strChar, | |
intLength, | |
strInput = [...arguments].join(''); | |
if (strInput.length === 0) { | |
return intHash; | |
} |
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
let a = [1, 2, 3, 4, 5, 6]; | |
let b = [1, 2, 3, 4, 5, 6]; | |
console.log('-- SLICE --'); | |
console.log('- Returns values which were removed'); | |
console.log('- Does not change the original array'); | |
console.log(a.slice(0, 2)); | |
console.log(a); | |
console.log(); |
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
/** | |
* @property {object} object - The object to query | |
* @property {string} path - The path of the property to get | |
* @property {object} fallback - The default value to return if no value found in path | |
* @returns {*} Returns the resolved value (undefined / fallback value / value found). | |
*/ | |
function get(object, path, fallback) { | |
const dot = path.indexOf('.'); | |
if (object === 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
const arr = [1, 2, 2, 8, 5, 5, 3, 8, 3]; | |
arr.sort().reduce((a, c) => { | |
if (a.includes(c)) { | |
return a; | |
} | |
a.push(c); | |
return a; | |
}, []); |