Last active
November 25, 2015 01:49
-
-
Save kentcdodds/5b48e47a87fa9448802a to your computer and use it in GitHub Desktop.
ng-nebraska talk files - Services - The Importance of Learning JavaScript and staying Marketable
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
export default {flatten} | |
function flatten(array) { | |
return array.reduce((a, b) => a.concat(b), []) | |
} |
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 angular from 'angular' | |
import emojiUtils from './emojiUtils' | |
angular.module('emojiApp') | |
.factory('emojiUtils', () => emojiUtils) |
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
angular.module('emojiApp') | |
.factory('emojiUtils', emojiUtils) | |
function emojiUtils() { | |
return {flatten} | |
function flatten(array) { | |
return array.reduce((a, b) => a.concat(b), []) | |
} | |
} |
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
describe('emojiUtils', function() { | |
beforeEach(module('emojiApp')) | |
beforeEach(inject(function(_emojiUtils_) { | |
emojiUtils = _emojiUtils_ | |
}) | |
describe('flatten', function() { | |
const {flatten} = emojiUtils | |
it('should flatten an array', function() { | |
const input = [[1], [2, 3], [4]] | |
const result = [1, 2, 3, 4] | |
expect(flatten(input)).to.deep.equal(result) | |
}) | |
}) | |
}) |
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 emojiUtils from './emojiUtils' | |
describe('emojiUtils', function() { | |
describe('flatten', function() { | |
const {flatten} = emojiUtils | |
it('should flatten an array', function() { | |
const input = [[1], [2, 3], [4]] | |
const result = [1, 2, 3, 4] | |
expect(flatten(input)).to.deep.equal(result) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment