function findKeyValue(paymentObj, key) {
const keySplit = key.split('.');
let value = '';
function findValue(obj, first, ...keys) {
if(typeof obj[first] === 'object') {
if(keys) {
findValue(obj[first], ...keys);
}
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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tempus, lacus ac pellentesque tincidunt, tortor libero laoreet sapien, eu ornare urna nunc tincidunt ipsum. Mauris elementum, lectus ut facilisis pulvinar, enim sapien pretium diam, eleifend elementum tellus diam in quam. Aenean dignissim ipsum aliquam, consectetur massa sit amet, dignissim nulla. Sed ex diam, dictum dapibus lacinia ac, viverra at tellus. Nunc vehicula lorem sit amet luctus bibendum. Vivamus fringilla metus eget venenatis malesuada. Praesent auctor risus ut dictum maximus. Proin quis vestibulum sapien. Vivamus fringilla, felis eu fringilla faucibus, diam ante euismod enim, nec ultrices elit mi eget justo. Vivamus id porttitor turpis. Phasellus sed nisl est. Sed fermentum suscipit justo, id vehicula quam tempor vitae.` | |
}); |
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 Ember from 'ember'; | |
const { computed } = Ember; | |
export default Ember.Component.extend({ | |
fullName: computed('firstName', 'lastName', function() { | |
console.log('Called in computed'); | |
const firstName = this.get('firstName'); | |
const lastName = this.get('lastName'); |
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
// finding value for deeply nested objects with object keys | |
function findKeyValue(paymentObj, key) { | |
const keySplit = key.split('.'); | |
let value = ''; | |
function findValue(obj, first, ...keys) { | |
if(typeof obj[first] === 'object') { | |
if(keys) { | |
findValue(obj[first], ...keys); |
This is the configuration steps to configure Jest testing framework for react applications.
npm install --save-dev jest
It loads all of the dependencies to work with jest, so you don't need to figure them out individually again.
- Add script for jest in package.json
{
....
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
// function Employee(name, dept) { | |
// this.name = name; | |
// this.dept = dept; | |
// } | |
// Employee.prototype = { | |
// getName() { | |
// return this.name; | |
// }, | |
// getDept() { |
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
//prettier | |
// create a .prettierrc file in project root folder | |
// in VScode - user.settings prettier.requireConfig: true and editor.formatOnSave: true | |
// prettier format | |
{ | |
"format": "prettier --write \"src/**/*.{js,jsx,css,json}\"" | |
} | |
// run this on CI server, to check difference in code format. |
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
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const root = j(file.source); | |
const match = /([a-zA-Z0-9\s_\\.\-\(\):])+(.scss)$/; | |
root | |
.find(j.ImportDeclaration) | |
.filter(path => match.test(path.value.source.value)) | |
.forEach(path => { | |
j(path).remove(); |
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
syntax on " enable syntax highlighting | |
set cursorline " highlight the current line | |
" set background=dark " darker color scheme | |
" set ruler " show line number in bar | |
set nobackup " don't create pointless backup files; Use VCS instead | |
set autoread " watch for file changes | |
set number " show line numbers | |
set showcmd " show selection metadata | |
set showmode " show INSERT, VISUAL, etc. mode | |
set showmatch " show matching brackets |