{{#includes myArray 'apple'}}
There is an apple!
{{/includes}}
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 { sliceByValue } from './sliceByValue'; | |
const array = [false, false, true, false, false, false]; | |
describe('sliceByValue', () => { | |
it('should slice by a boolean type value', () => { | |
expect(sliceByValue(array, true)).toEqual([false, false, false]); | |
}); | |
it('should slice by a boolean type value when its the last element', () => { |
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
/** | |
* This function returns an ID that depends on UTC | |
* !WARNING! It might return non-unique ID when the function | |
* will call more than one time in one milliseconds | |
* generateUTCId() === generateUTCId() // true | |
*/ | |
export const generateUTCId = (): number => { | |
const date = new Date(); | |
const components = [ |
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
const isArray = (item) => Array.isArray(item); | |
const isObject = (item) => | |
item !== null && isArray(item) === false && typeof item === 'object'; | |
const isFunction = (item) => typeof item === 'function'; | |
const isBoolean = (item) => typeof item === 'boolean'; | |
const hasOwnPrototypeOfToString = (object) => |
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 hasOwnProperty from './hasOwnProperty'; | |
const object = { | |
name: 'John', | |
get userName(): string { | |
return object.name; | |
}, | |
set setUserName(name: string) { | |
object.name = name; | |
}, |
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 isValidVin from './isValidVin.ts'; | |
describe('isValidVin', () => { | |
it('should return false for an invalid 16 digit VIN', () => { | |
const vin = 'JHLRM4H70CC01839'; | |
expect(isValidVin(vin)).toBe(false); | |
}); | |
it('should return false for an invalid 18 digit VIN', () => { |
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 toCamelCase from './toCamelCase'; | |
describe('toCamelCase', () => { | |
it('should return a correct result for an underscore style', () => { | |
expect(toCamelCase('under_score')).toBe('underScore'); | |
}); | |
it('should return a correct result for a kebab style', () => { | |
expect(toCamelCase('kebab-style')).toBe('kebabStyle'); | |
}); |
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 createMD5Signature from './createMD5Signature'; | |
describe('createMD5Signature', () => { | |
it('should return a correct hash', () => { | |
expect(createMD5Signature('JohnSmith:9129s$aW}a1')).toBe( | |
'6436241bc4170549efac409b8a4fc43f' | |
); | |
}); | |
}); |
This function collects object values { a: 1, b: 2 } => [1, 2] { c: { d: 3, e: 4 } } => [3, 4]