From dc7b996390f9221c66cc8eb0ce586b97a20aea9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gordan=20Neki=C4=87?= Date: Thu, 14 Jun 2018 16:21:37 +0200 Subject: [PATCH 1/2] Add Croatia style to extras --- README.md | 1 + examples/normal-usage.js | 1 + examples/safe-string.js | 1 + index.d.ts | 2 ++ lib/colors.js | 1 + lib/extendStringPrototype.js | 4 ++++ lib/maps/croatia.js | 11 +++++++++++ safe.d.ts | 1 + 8 files changed, 22 insertions(+) create mode 100644 lib/maps/croatia.js diff --git a/README.md b/README.md index 4bebb6c9..a5144693 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Please check out the [roadmap](ROADMAP.md) for upcoming features and releases. - rainbow - zebra - america + - croatia - trap - random diff --git a/examples/normal-usage.js b/examples/normal-usage.js index cc8d05ff..17e5cd6f 100644 --- a/examples/normal-usage.js +++ b/examples/normal-usage.js @@ -28,6 +28,7 @@ console.log('This is ' + 'not'.strikethrough + ' fun.'); console.log('Background color attack!'.black.bgWhite); console.log('Use random styles on everything!'.random); console.log('America, Heck Yeah!'.america); +console.log('HRVATSKA!'.croatia); console.log('Setting themes is useful'); diff --git a/examples/safe-string.js b/examples/safe-string.js index 7a836537..be29840e 100644 --- a/examples/safe-string.js +++ b/examples/safe-string.js @@ -27,6 +27,7 @@ console.log('This is ' + colors.strikethrough('not') + ' fun.'); console.log(colors.black.bgWhite('Background color attack!')); console.log(colors.random('Use random styles on everything!')); console.log(colors.america('America, Heck Yeah!')); +console.log(colors.croatia('HRVATSKA!')); console.log('Setting themes is useful'); diff --git a/index.d.ts b/index.d.ts index faa9ab69..2ae12dca 100644 --- a/index.d.ts +++ b/index.d.ts @@ -41,6 +41,7 @@ export interface Color { rainbow: Color; zebra: Color; america: Color; + croatia: Color; trap: Color; random: Color; zalgo: Color; @@ -87,6 +88,7 @@ export const strikethrough: Color; export const rainbow: Color; export const zebra: Color; export const america: Color; +export const croatia: Color; export const trap: Color; export const random: Color; export const zalgo: Color; diff --git a/lib/colors.js b/lib/colors.js index bbc5ac12..902c3a6b 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -184,6 +184,7 @@ colors.zalgo = require('./custom/zalgo'); // maps colors.maps = {}; colors.maps.america = require('./maps/america'); +colors.maps.croatia = require('./maps/croatia'); colors.maps.zebra = require('./maps/zebra'); colors.maps.rainbow = require('./maps/rainbow'); colors.maps.random = require('./maps/random'); diff --git a/lib/extendStringPrototype.js b/lib/extendStringPrototype.js index ed608f66..acb3164d 100644 --- a/lib/extendStringPrototype.js +++ b/lib/extendStringPrototype.js @@ -40,6 +40,10 @@ module['exports'] = function() { return colors.america(this); }); + addProperty('croatia', function() { + return colors.croatia(this); + }); + // // Iterate through all default styles and colors // diff --git a/lib/maps/croatia.js b/lib/maps/croatia.js new file mode 100644 index 00000000..3a6a2488 --- /dev/null +++ b/lib/maps/croatia.js @@ -0,0 +1,11 @@ +var colors = require('../colors'); + +module['exports'] = (function() { + return function(letter, i, exploded) { + if (letter === ' ') return letter; + switch (i%2) { + case 0: return colors.red(letter); + case 1: return colors.white(letter); + } + }; +})(); diff --git a/safe.d.ts b/safe.d.ts index 2bafc279..19fc9d2e 100644 --- a/safe.d.ts +++ b/safe.d.ts @@ -43,6 +43,7 @@ export function strikethrough(str: string): string; export function rainbow(str: string): string; export function zebra(str: string): string; export function america(str: string): string; +export function croatia(str: string): string; export function trap(str: string): string; export function random(str: string): string; export function zalgo(str: string): string; From 777f691f166767d5a3f6e3dcb6ebc4b4c72eee7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gordan=20Neki=C4=87?= Date: Thu, 14 Jun 2018 23:20:00 +0200 Subject: [PATCH 2/2] Enhance Croatia style with background color --- lib/maps/croatia.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/maps/croatia.js b/lib/maps/croatia.js index 3a6a2488..dadabeb6 100644 --- a/lib/maps/croatia.js +++ b/lib/maps/croatia.js @@ -4,8 +4,8 @@ module['exports'] = (function() { return function(letter, i, exploded) { if (letter === ' ') return letter; switch (i%2) { - case 0: return colors.red(letter); - case 1: return colors.white(letter); + case 0: return colors.bgRed(colors.white(letter)); + case 1: return colors.bgWhite(colors.red(letter)); } }; })();