-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0e564d5
Showing
10 changed files
with
778 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "airbnb", | ||
"env": { | ||
"node": true, | ||
"mocha": true | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
logs | ||
*.log | ||
npm-debug.log* | ||
lib | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
logs | ||
*.log | ||
npm-debug.log* | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2015 Evgeni Korsunov <5345043@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Text 2 smiles | ||
|
||
Special text converter for easy converting text to something like this: | ||
|
||
``` | ||
🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈 | ||
🙈🎱🙈🙈🎱🙈🙈🎱🎱🎱🎱🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🎱🎱🎱🙈🙈🙈🙈🙈🙈🙈 | ||
🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈🙈🙈🙈🙈🙈🙈 | ||
🙈🎱🎱🎱🎱🙈🙈🎱🎱🎱🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈🙈🙈🙈🙈🙈🙈 | ||
🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🙈🙈 | ||
🙈🎱🙈🙈🎱🙈🙈🎱🎱🎱🎱🙈🙈🎱🎱🎱🎱🙈🙈🎱🎱🎱🎱🙈🙈🎱🎱🎱🎱🙈🙈🎱🙈🙈🙈🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈🙈🎱🎱🎱🎱🙈🙈🎱🎱🎱🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🎱🎱🙈🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🎱🎱🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🎱🎱🎱🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🙈🎱🙈🙈🙈🎱🙈🙈🙈🙈🙈🎱🙈🙈🎱🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🙈🎱🎱🙈🙈🙈🎱🎱🎱🎱🙈🙈🎱🙈🙈🎱🙈🙈🎱🎱🎱🎱🙈🙈🎱🎱🎱🙈🙈 | ||
🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈🙈 | ||
``` | ||
|
||
## Installing | ||
|
||
``` | ||
npm install text2smiles --save | ||
``` | ||
|
||
### How to use | ||
|
||
```javascript | ||
convertText2Smiles(text, [backgroundSmile = '🤘', textSmile = '💀', countSymbolsOnTheRow = 8]); | ||
|
||
``` | ||
### Example | ||
|
||
```javascript | ||
// var convertText2Smiles = require('text2smiles').default; | ||
import convertText2Smiles from 'text-of-smiles'; | ||
|
||
// should display the text above | ||
console.log(convertText2Smiles('hello, world', '🙈', '🎱', 6)); | ||
|
||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "text2smiles", | ||
"version": "1.0.3", | ||
"description": "Converting text to smiles", | ||
"keywords": [ | ||
"emoji", | ||
"smiles", | ||
"text to emoji", | ||
"text to symbols", | ||
"converting text" | ||
], | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"lint": "./node_modules/.bin/eslint ./src", | ||
"transpile-es2015": "babel src -d lib", | ||
"test": "./node_modules/mocha/bin/mocha --compilers js:babel-core/register ./src/tests", | ||
"test-all": "npm run lint && npm run test", | ||
"preinstall": "npm run transpile-es2015" | ||
}, | ||
"author": "Evgeni Korsunov<5345043@gmail.com>", | ||
"dependencies": { | ||
"babel-core": "^6.22.1", | ||
"babel-preset-es2015": "^6.22.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^3.15.0", | ||
"eslint-config-airbnb": "^14.1.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jsx-a11y": "^3.0.2", | ||
"eslint-plugin-react": "^6.9.0", | ||
"mocha": "^3.2.0" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url" : "https://github.com/sensone/text2smiles.git" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ABC, LETTER_WIDTH, LETTER_HEIGHT } from './serift'; | ||
|
||
const STRING_LENGTH = 8; | ||
|
||
export default function convertText2Smiles(text = '', symb1 = '🤘', symb2 = '💀', strLength = STRING_LENGTH) { | ||
if (!text.length) return text; | ||
|
||
function getLetter(symb, lineIndex) { | ||
let letter; | ||
|
||
switch (symb) { | ||
case "'": | ||
letter = ABC.quote; | ||
break; | ||
default: | ||
letter = ABC[symb]; | ||
} | ||
|
||
if (!letter) { | ||
letter = ABC[' ']; | ||
} | ||
|
||
return letter.slice((lineIndex * LETTER_WIDTH), (lineIndex * LETTER_WIDTH) + LETTER_WIDTH); | ||
} | ||
|
||
function generateLine(str, result = '') { | ||
let currentResult = result; | ||
const currentString = str.slice(0, strLength); | ||
const surplusString = str.slice(strLength); | ||
|
||
for (let lineIndex = 0; lineIndex < LETTER_HEIGHT; lineIndex += 1) { | ||
for (let letterIndex = 0; letterIndex < currentString.length; letterIndex += 1) { | ||
const letter = currentString[letterIndex]; | ||
|
||
currentResult += getLetter(letter, lineIndex); | ||
} | ||
|
||
currentResult += '\n'; | ||
} | ||
|
||
if (surplusString.length > 0) { | ||
return generateLine(surplusString, currentResult); | ||
} | ||
|
||
return currentResult; | ||
} | ||
|
||
return generateLine(text.toLowerCase()).replace(/\./g, symb1).replace(/\*/g, symb2); | ||
} |
Oops, something went wrong.