├── .gitignore ├── tsconfig.json ├── .eslintrc.js ├── README.md ├── ts_src ├── index.spec.ts └── index.ts └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | ts_build -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "ts_build", 4 | "module": "commonjs", 5 | "target": "es6" 6 | }, 7 | "include": [ 8 | "ts_src/*.ts" 9 | ] 10 | } -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: false, 4 | commonjs: true, 5 | es6: true, 6 | node: true 7 | }, 8 | extends: [ 9 | '@quartz/eslint-config-base' 10 | ], 11 | parser: '@typescript-eslint/parser', 12 | parserOptions: { 13 | ecmaVersion: 2018 14 | }, 15 | plugins: [ 16 | '@typescript-eslint' 17 | ], 18 | settings: { 19 | "import/resolver": { 20 | node: { 21 | extensions: [".js", ".jsx", ".ts", ".tsx"] 22 | } 23 | }, 24 | }, 25 | overrides: [{ 26 | files: [ "*.ts" ], 27 | rules: { 28 | "no-unused-vars": 0, 29 | "jest/valid-expect": 0, 30 | } 31 | }] 32 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # is-go-go-day 2 | 3 | Determine if a day is a [GO! GO! Day](https://gogocurryamerica.com/). 4 | 5 | ```js 6 | const { isGoGoDay } = require( '@quartz/is-go-go-day' ); 7 | 8 | console.log( isGoGoDay() ); 9 | 10 | console.log( isGoGoDay( new Date('2020-01-14') ) ); 11 | 12 | console.log( isGoGoDay( new Date('2020-01-15T00:00:00-05:00') ) ); 13 | ``` 14 | 15 | Or get a list of all GO! GO! Days for a given year. 16 | 17 | ```js 18 | const { getGoGoDays } = require( '@quartz/is-go-go-day' ); 19 | 20 | console.log ( getGoGoDays( 2020 ) ); 21 | ``` 22 | 23 | # Development 24 | 25 | To build: `npm run build` 26 | 27 | To run tests: `npm test` 28 | 29 | To run lint: `npm run lint` To autofix: `npm run lint:fix` 30 | -------------------------------------------------------------------------------- /ts_src/index.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | isGoGoDay, 3 | getGoGoDays, 4 | } from '.'; 5 | 6 | import 'mocha'; 7 | import { expect } from 'chai'; 8 | 9 | describe( 'isGoGoDay', () => { 10 | it( 'should work for any given dates', () => { 11 | expect( isGoGoDay( new Date( '2019-12-24T00:00:00-05:00' ) ) ).to.be.false; 12 | expect( isGoGoDay( new Date( '2019-12-25T00:00:00-05:00' ) ) ).to.be.true; 13 | } ); 14 | } ); 15 | 16 | describe( 'getGoGoDays', () => { 17 | it( 'should list all go go days for a given year', () => { 18 | expect( getGoGoDays( 2020 ) ).to.have.lengthOf( 36 ); 19 | expect( getGoGoDays( 2020 )[0] ).to.equal( '2020-01-05' ); 20 | expect( getGoGoDays( 2020 )[35] ).to.equal( '2020-12-25' ); 21 | } ); 22 | 23 | it( 'should throw an error', () => { 24 | expect( () => getGoGoDays( 1999 ) ).to.throw( Error ); 25 | } ); 26 | } ); 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@quartz/is-go-go-day", 3 | "version": "1.1.0", 4 | "description": "", 5 | "main": "ts_build/index.js", 6 | "files": [ 7 | "ts_build/**/*" 8 | ], 9 | "scripts": { 10 | "build": "tsc", 11 | "test": "mocha -r ts-node/register ts_src/*.spec.ts", 12 | "lint": "./node_modules/.bin/eslint --ignore-path .gitignore --ext=.js,.ts .", 13 | "lint:fix": "./node_modules/.bin/eslint --fix --ignore-path .gitignore --ext=.js,.ts .", 14 | "prepare": "npm run build", 15 | "prepublishOnly": "npm test && npm run lint", 16 | "preversion": "npm run lint" 17 | }, 18 | "devDependencies": { 19 | "@quartz/eslint-config-base": "^1.2.0", 20 | "@types/chai": "^4.2.7", 21 | "@types/mocha": "^5.2.7", 22 | "@typescript-eslint/eslint-plugin": "^2.16.0", 23 | "@typescript-eslint/parser": "^2.16.0", 24 | "chai": "^4.2.0", 25 | "eslint": "^6.8.0", 26 | "mocha": "^7.0.0", 27 | "ts-node": "^8.6.2", 28 | "typescript": "^3.7.4" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ts_src/index.ts: -------------------------------------------------------------------------------- 1 | // The static list of GO! GO! days in a year. 2 | const GO_GO_DAYS: Array = [ 3 | '01-05', 4 | '01-15', 5 | '01-25', 6 | '02-05', 7 | '02-15', 8 | '02-25', 9 | '03-05', 10 | '03-15', 11 | '03-25', 12 | '04-05', 13 | '04-15', 14 | '04-25', 15 | '05-05', 16 | '05-15', 17 | '05-25', 18 | '06-05', 19 | '06-15', 20 | '06-25', 21 | '07-05', 22 | '07-15', 23 | '07-25', 24 | '08-05', 25 | '08-15', 26 | '08-25', 27 | '09-05', 28 | '09-15', 29 | '09-25', 30 | '10-05', 31 | '10-15', 32 | '10-25', 33 | '11-05', 34 | '11-15', 35 | '11-25', 36 | '12-05', 37 | '12-15', 38 | '12-25', 39 | ]; 40 | 41 | const isGoGoDay = ( date: Date = new Date() ) => date.getDate().toString().endsWith( '5' ); 42 | 43 | const getGoGoDays = ( year: number ) => { 44 | // Expect a reasonable year. This code will die. 45 | if ( year < 2000 || year >= 2100 ) { 46 | throw new Error( 'Please provide a year in this century.' ); 47 | } 48 | 49 | return GO_GO_DAYS.map( it => `${year}-${it}` ); 50 | }; 51 | 52 | export { 53 | getGoGoDays, 54 | isGoGoDay, 55 | }; 56 | --------------------------------------------------------------------------------