Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
v1.0.0 (#1)
Browse files Browse the repository at this point in the history
* Add ESLint with `node` plugin
* Remove `*.lock` from `.gitignore`
* Refactor `package.json`
* Text changes in `README.md`
* Add `yarn.lock` file
* Some code cleanups
  • Loading branch information
sergejmueller committed Oct 28, 2016
1 parent abbd7b1 commit d1d9b1f
Show file tree
Hide file tree
Showing 10 changed files with 996 additions and 28 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"plugins": ["node"],
"extends": ["eslint:recommended", "plugin:node/recommended"],
"env": {
"mocha": true,
"node": true
},
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-console": 0
}
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ node_modules
.npm
logs
*.log
*.lock
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ node_js:
- "4"
- "0.12"
- "0.11"
- "0.10"
- "0.10"
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# rtrim / CHANGELOG


### v1.0.0 (2016-10-28)

* Add ESLint with `node` plugin
* Remove `*.lock` from `.gitignore`
* Refactor `package.json`
* Text changes in `README.md`
* Add `yarn.lock` file
* Some code cleanups


### v0.0.3 (2016-06-17)

* Cleanup readme
Expand All @@ -10,4 +23,4 @@

### v0.0.1 (2016-06-16)

* Initial commit

* Initial commit

20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rtrim
============

`rtrim` [Node.js module](https://www.npmjs.com/package/rtrim) returns a string with whitespace (or other characters) stripped from the end of a string. Without dependencies and library bloat.
`rtrim` Node.js module returns a string with whitespace (or other characters) stripped from the end of a string. Without dependencies and library bloat.


[![Dependency Status](https://david-dm.org/sergejmueller/rtrim.svg)](https://david-dm.org/sergejmueller/rtrim)
Expand All @@ -13,20 +13,28 @@ rtrim
Install
-----

```
```bash
npm install rtrim
```

*or*

```bash
yarn add rtrim
```


Usage
-----

```javascript
rtrim ( str [, chars ] )
rtrim( str [, chars ] )
```

`str` → The input string<br>
`chars` → Characters that you want to be stripped
Parameter | Description
--- | ---
`str` | The input string
`chars` | Characters that you want to be stripped

Without the second parameter, `rtrim` will strip whitespaces (spaces, tabs and new lines).

Expand All @@ -35,7 +43,7 @@ Examples
-----

```javascript
var rtrim = require('rtrim');
var rtrim = require( 'rtrim' );


/* Strip whitespace from the end of a string */
Expand Down
2 changes: 1 addition & 1 deletion examples/rtrim.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";


var rtrim = require('..');
var rtrim = require( '..' );


/**
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ module.exports = function ( str, chars ) {
chars = chars.toString();

// Set vars
var letters = str.split(''),
var letters = str.split( '' ),
i = letters.length - 1;

// Loop letters
for ( i; i >= 0; i --) {
for ( i; i >= 0; i -- ) {
if ( chars.indexOf( letters[i] ) === -1 ) {
return str.substring(0, i + 1);
return str.substring( 0, i + 1 );
}
}

Expand Down
26 changes: 16 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "rtrim",
"version": "0.0.3",
"version": "1.0.0",
"description": "Strip whitespace - or other characters - from the end of a string",
"main": "index.js",
"files": [
"index.js"
],
"scripts": {
"test": "mocha"
"test": "mocha",
"lint": "eslint ."
},
"keywords": [
"trim",
Expand All @@ -17,15 +21,17 @@
"url": "https://sergejmueller.github.io"
},
"homepage": "https://github.com/sergejmueller/rtrim",
"repository": {
"type": "git",
"url": "https://github.com/sergejmueller/rtrim.git"
},
"repository": "sergejmueller/rtrim",
"license": "MIT",
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.1.2",
"array-range": "^1.0.1",
"shuffle-array": "^1.0.0"
"array-range": "^1.0.1",
"chai": "^3.5.0",
"eslint": "^3.8.1",
"eslint-plugin-node": "^2.1.3",
"mocha": "^3.1.2",
"shuffle-array": "^1.0.0"
},
"engines": {
"node": ">=0.10"
}
}
10 changes: 5 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";


var rtrim = require('..'),
range = require('array-range'),
shuffle = require('shuffle-array'),
expect = require('chai').expect;
var rtrim = require( '..' ),
range = require( 'array-range' ),
shuffle = require( 'shuffle-array' ),
expect = require( 'chai' ).expect;


describe( 'Strip characters from the end of a string', function() {
Expand Down Expand Up @@ -67,6 +67,6 @@ var shuffledSpecialChars = function() {
chars.push( String.fromCharCode( _ ) );
} );

return shuffle( chars ).join('');
return shuffle( chars ).join( '' );

}

0 comments on commit d1d9b1f

Please sign in to comment.