Skip to content

Commit

Permalink
Implement minimum viable product
Browse files Browse the repository at this point in the history
  • Loading branch information
julkue committed Jan 19, 2018
1 parent c497be3 commit a399dbd
Show file tree
Hide file tree
Showing 15 changed files with 496 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = LF
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
126 changes: 126 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"extends": [
"eslint:recommended"
],
"env": {
"commonjs": true,
"node": true,
"es6": true,
"jasmine": true
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
},
"sourceType": "module"
},
"rules": {
"no-template-curly-in-string": "error",
"array-callback-return": "error",
"block-scoped-var": "error",
"default-case": "error",
"no-fallthrough": "error",
"no-global-assign": "error",
"no-extend-native": "error",
"no-invalid-this": "warn",
"eqeqeq": "warn",
"no-alert": "error",
"no-eval": "error",
"no-with": "error",
"consistent-return": "warn",
"curly": "warn",
"no-tabs": "error",
"arrow-spacing": "error",
"no-undefined": "error",
"global-require": "error",
"no-var": "error",
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"max-len": [
"error",
{
"ignoreStrings": false,
"ignoreTrailingComments": false,
"ignoreComments": false,
"code": 80
}
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"dot-location": [
"error",
"property"
],
"brace-style": [
"error",
"1tbs"
],
"camelcase": [
"error",
{
"properties": "always"
}
],
"no-console": 0,
"space-before-function-paren": [
"error",
"never"
],
"keyword-spacing": [
"error",
{
"before": true,
"after": true
}
],
"array-bracket-spacing": [
"error",
"never"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"complexity": [
"error",
10
],
"max-depth": [
"error",
8
],
"valid-jsdoc": [
"error",
{
"prefer": {
"arg": "param"
},
"requireReturn": false,
"requireReturnDescription": false,
"requireParamDescription": false,
"preferType": {
"Boolean": "boolean",
"Number": "number",
"Object": "object",
"String": "string"
}
}
]
}
}
23 changes: 23 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md diss=astextplain
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Eclipse
.settings/
.project
.buildpath

# Webstorm
.idea/

# Dependencies
node_modules/

# Personal
TODO
npm-debug.log*
31 changes: 31 additions & 0 deletions .jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"js": {
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"wrap_line_length": 80,
"indent_size": 2,
"keep_array_indentation": false,
"jslint_happy": true,
"end_with_newline": true,
"preserve_newlines": true
},
"html": {
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"indent_size": 2,
"extra_liners": [],
"wrap_line_length": 80
},
"css": {
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"indent_size": 2,
"align_assignments": false,
"convert_quotes": "double",
"preserve_newlines": true,
"newline_between_rules": false
}
}
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "stable"
script:
- npm test
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Julian Kühnel <[email protected]>
Rob Garrison <[email protected]>
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Contributing

## Development

_Requirements: Latest [Node.js][node-js] (includes npm)_

To install the modules needed for developing, you should clone or download this repository then run:

```bash
$ npm install
```

If you want to add a new function, please open an issue for discussion first. And after we have discussed and approved the modification, please add appropriate tests before submitting a pull request.

After you have contributed something check your code by using:

```bash
$ npm test
```

# Contribution and License Agreement

If you contribute to this project, you are implicitly allowing your code to be distributed under [this license][license]. You are also implicitly verifying that all code is your original work.

[license]: https://git.io/v1EBe
[node-js]: https://nodejs.org/en/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Julian Motz
Copyright (c) 2018 The Diacritics Authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# node-diacritics-transliterator

> Diacritic transliteration tool using the diacritics.io API
# Installation

```bash
$ npm install diacritics-transliterator
```

# Module

The module exports an object with the following functions:

## replace()

This function replaces a placeholder inside a string with an array of equivalent diacritics and their mappings. You can use it e.g. to create a regular expression.

**Parameters**:

_input_

Type: `string`

A string of JavaScript code.

_options_

Type: `object`
Optional: `true`

An object of options:

| Name | Type | Default | Description |
|-------------|--------|-----------------------|---------------------------------------------------------------------------------------------------|
| placeholder | string | '// <% diacritics %>' | The placeholder that will be replaced with an array of equivalent diacritics and their mappings |
| type | string | 'const' | The variable type |
| name | string | 'diacritics' | The variable name |
57 changes: 57 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "diacritics-transliterator",
"version": "0.1.0",
"description": "Diacritic transliteration tool using the diacritics.io API",
"main": "src/main.js",
"scripts": {
"start": "nodemon test/test.js",
"test": "npm run lint && npm run jasmine",
"lint": "eslint src/",
"jasmine": "jasmine test/test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/diacritics/node-diacritics-transliterator.git"
},
"keywords": [
"accents",
"alphabet",
"continent",
"diacritic",
"search",
"language",
"variant",
"database",
"latinize",
"decompose",
"normalize",
"transliterate",
"placeholders",
"RegExp",
"unicode",
"utf8"
],
"author": "The Diacritics Authors",
"maintainers": [
{
"name": "Julian Kühnel",
"url": "https://github.com/julmot"
},
{
"name": "Rob Garrison",
"url": "https://github.com/Mottie"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/diacritics/node-diacritics-transliterator/issues"
},
"devDependencies": {
"eslint": "^4.15.0",
"jasmine": "^2.9.0",
"nodemon": "^1.14.11"
},
"dependencies": {
"node-fetch": "^1.7.3"
}
}
25 changes: 25 additions & 0 deletions src/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*!***************************************************
* node-diacritics-transliterator
* http://diacritics.io/
* Copyright (c) 2018 The Diacritics Authors
* Released under the MIT license https://git.io/v1EBe
*****************************************************/
'use strict';
const nodeFetch = require('node-fetch');

const fetch = () => {
const url = 'https://api.diacritics.io/v1/';
return new Promise((resolve, eject) => {
nodeFetch(url).then(res => res.json(), err => {
return eject(err.message);
}).then(json => {
if (json) {
resolve(json);
} else {
eject();
}
});
});
};

module.exports = fetch;
12 changes: 12 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!***************************************************
* node-diacritics-transliterator
* http://diacritics.io/
* Copyright (c) 2018 The Diacritics Authors
* Released under the MIT license https://git.io/v1EBe
*****************************************************/
'use strict';
const replace = require('./replace.js');

module.exports = {
replace
};
Loading

0 comments on commit a399dbd

Please sign in to comment.