Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Nov 28, 2015
0 parents commit 9e60235
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.swp
*.swo
*~
*.log
node_modules
64 changes: 64 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# :eight_spoked_asterisk: :stars: :sparkles: :dizzy: :star2: :star2: :sparkles: :dizzy: :star2: :star2: Contributing :star: :star2: :dizzy: :sparkles: :star: :star2: :dizzy: :sparkles: :stars: :eight_spoked_asterisk:

So, you want to contribute to this project! That's awesome. However, before
doing so, please read the following simple steps how to contribute. This will
make the life easier and will avoid wasting time on things which are not
requested. :sparkles:

## Discuss the changes before doing them
- First of all, open an issue in the repository, using the [bug tracker][1],
describing the contribution you would like to make, the bug you found or any
other ideas you have. This will help us to get you started on the right
foot.

- If it makes sense, add the platform and software information (e.g. operating
system, Node.JS version etc.), screenshots (so we can see what you are
seeing).

- It is recommended to wait for feedback before continuing to next steps.
However, if the issue is clear (e.g. a typo) and the fix is simple, you can
continue and fix it.

## Fixing issues
- Fork the project in your account and create a branch with your fix:
`some-great-feature` or `some-issue-fix`.

- Commit your changes in that branch, writing the code following the
[code style][2]. If the project contains tests (generally, the `test`
directory), you are encouraged to add a test as well. :memo:

- If the project contains a `package.json` or a `bower.json` file add yourself
in the `contributors` array (or `authors` in the case of `bower.json`;
if the array does not exist, create it):

```json
{
"contributors": [
"Your Name <and@email.address> (http://your.website)"
]
}
```

## Creating a pull request

- Open a pull request, and reference the initial issue in the pull request
message (e.g. *fixes #<your-issue-number>*). Write a good description and
title, so everybody will know what is fixed/improved.

- If it makes sense, add screenshots, gifs etc., so it is easier to see what
is going on.

## Wait for feedback
Before accepting your contributions, we will review them. You may get feedback
about what should be fixed in your modified code. If so, just keep committing
in your branch and the pull request will be updated automatically.

## Everyone is happy!
Finally, your contributions will be merged, and everyone will be happy! :smile:
Contributions are more than welcome!

Thanks! :sweat_smile:

[1]: https://github.com/IonicaBizau/indento/issues

[2]: https://github.com/IonicaBizau/code-style
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) -15 Ionică Bizău <bizauionica@gmail.com> (http://ionicabizau.net)

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.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# indento [![Support this project][donate-now]][paypal-donations]

Indent strings.

## Installation

```sh
$ npm i indento
```

## Example

```js
const indento = require("indento");

console.log(indento("Hello World", 4));
// => "Hello World"

console.log(indento("Hello\nMars", 1));
// =>
// Hello
// Mars

console.log(indento("Hello\nPluto", 2, "a"));
// =>
// aaHello
// aaPluto
```

## Documentation

### `indento(input, width, char)`
Indents the input string.

#### Params
- **String** `input`: The input string.
- **Number** `width`: The indent width.
- **String** `char`: The character to use for indentation (default: `" "`).

#### Return
- **String** The indented string.

## How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].

## Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:

## License

MIT © [Ionică Bizău][website]

[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
[donate-now]: http://i.imgur.com/6cMbHOC.png

[website]: http://ionicabizau.net
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md
14 changes: 14 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const indento = require("../lib");

console.log(indento("Hello World", 4));
// => "Hello World"

console.log(indento("Hello\nMars", 1));
// =>
// Hello
// Mars

console.log(indento("Hello\nPluto", 2, "a"));
// =>
// aaHello
// aaPluto
17 changes: 17 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* indento
* Indents the input string.
*
* @name indento
* @function
* @param {String} input The input string.
* @param {Number} width The indent width.
* @param {String} char The character to use for indentation (default: `" "`).
* @return {String} The indented string.
*/
function indento(input, width, char) {
char = char || " ";
return input.replace(/^/gm, char.repeat(width));
}

module.exports = indento;
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "indento",
"version": "1.0.0",
"description": "Indent strings.",
"main": "lib/index.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/IonicaBizau/indento.git"
},
"keywords": [
"indent",
"string",
"width",
"custom",
"character"
],
"author": "Ionică Bizău <bizauionica@gmail.com> (http://ionicabizau.net)",
"license": "MIT",
"bugs": {
"url": "https://github.com/IonicaBizau/indento/issues"
},
"homepage": "https://github.com/IonicaBizau/indento#readme"
}

0 comments on commit 9e60235

Please sign in to comment.