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 const toCamelCase = (str: string, firstLowerCase = true): string => | |
| str | |
| .split(/(?=(?:(?<![A-Z])[A-Z])|(?:(?<!\d)\d))|[-_]/) | |
| .map( | |
| ([first, ...rest], index) => | |
| (firstLowerCase && index === 0 | |
| ? first.toLowerCase() | |
| : first.toUpperCase()) + rest.join("").toLowerCase() | |
| ) | |
| .join(""); |
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 LOCALES_TO_START_OF_WEEK = { | |
| 'af-ZA': 7, | |
| 'am-ET': 7, | |
| 'ar-AE': 1, | |
| 'ar-BH': 6, | |
| 'ar-DZ': 1, | |
| 'ar-EG': 6, | |
| 'ar-IQ': 6, | |
| 'ar-JO': 7, | |
| 'ar-KW': 6, |
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
| Tag = ContainerTag / SelfClosingTag | |
| ContainerTag = OpeningBracket name:Text attributes:Attributes ClosingBracket children:Tag* OpeningBracket Slash closingName:Text ClosingBracket { | |
| if (name !== closingName) { | |
| throw new Error('Missmatching closing tag') | |
| } | |
| return {name, children, attributes} | |
| } | |
| SelfClosingTag = OpeningBracket name:Text attributes:Attributes _ Slash ClosingBracket { return {name, attributes} } |
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 * as sinon from 'sinon'; | |
| import * as Mongoose from 'mongoose'; | |
| import { expect } from 'chai'; | |
| // test utility | |
| function areObjectIdsEqual(id1: Mongoose.Types.ObjectId | string, id2: Mongoose.Types.ObjectId | string) { | |
| let normalizedId1: Mongoose.Types.ObjectId = new Mongoose.Types.ObjectId(id1.toString()); | |
| let normalizedId2: Mongoose.Types.ObjectId = new Mongoose.Types.ObjectId(id2.toString()); | |
| return normalizedId1.equals(normalizedId2); | |
| } |
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 PrivateFactory(scope) { | |
| scope._ = function(fn) { | |
| return function() { | |
| return fn.apply(scope, arguments) | |
| } | |
| } | |
| } | |
| var Greeter = (function() { |
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
| #!/bin/bash | |
| # Form from https://gist.github.com/robwierzbowski/5430952/ | |
| # Create a remote repo on GitHub and clone it to your computer | |
| # Grabs sensible defaults from the containing folder and `.gitconfig`. | |
| # Refinements welcome. | |
| # Get user input | |
| echo "New repo name:" | |
| read REPONAME |