Skip to content

Commit

Permalink
release: v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharf5 committed Sep 12, 2021
1 parent 45322d0 commit 791b2e5
Show file tree
Hide file tree
Showing 36 changed files with 4,149 additions and 3,085 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
reactComponentLib
30 changes: 19 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: 'airbnb-base',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:react-hooks/recommended',
],
rules: {
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_|^req|^next' }],
'react/prop-types': 0,
'no-console': 'error',
},
};
7 changes: 4 additions & 3 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
node_modules
/coverage/
settings.json
lib/get-class-names.js
dist
.rpt2_cache
docs/src/latest/
16 changes: 12 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
src
test.js
static/*
.circleci/*
/docs/
/src/
/.vscode/
/build/
/test/
README.md
.prettierrc
.npmrc
.npmignore
.gitignore
.eslintignore
.eslintrc.js
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry = "https://registry.npmjs.com/"
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/dist/
/node_modules/
/build/
/docs/src/latest/
/docs/build/
8 changes: 5 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"useTabs": false,
"printWidth": 80
}
"printWidth": 120,
"tabWidth": 2
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"jira-plugin.workingProject": ""
}
67 changes: 35 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

Features:

* Support string arguments.
* Support number arguments.
* Support object arguments.
* Support array arguments.
* Support function arguments.
* No dependency.
- Support string arguments.
- Support number arguments.
- Support object arguments.
- Support array arguments.
- Support function arguments.
- No dependency.

## Quickstart - CommonJS

Expand All @@ -44,73 +44,76 @@ yarn add dynamic-class-list

Then require it in your module ...


```javascript
var getClassNames = require('dynamic-class-list').getClassNames; // deprecated
var classList = require('dynamic-class-list').classList;
var cl = require('dynamic-class-list').cl;
```

## OR using ES6 imports


```javascript
import { getClassNames, classList } from 'dynamic-class-list';
import { cl } from 'dynamic-class-list';
```

Note that `getClassNames` is deprecated and will be removed in next major release. You should use `classList` moving forward.

## API

### Arguments as strings

```javascript

// As Arguments
getClassNames('class1', 'class2'); // Output ==> "class1 class2"
// OR
classList('class1', 'class2'); // Output ==> "class1 class2"
cl('class1', 'class2'); // Output ==> "class1 class2"
```

### Arguments as an array of strings


```javascript
classList(['class1', 'class2']); // Output ==> "class1 class2"
cl(['class1', 'class2']); // Output ==> "class1 class2"

classList([null, undefined, 3, 'class1', 'class2']); // Output ==> "3 class1 class2"
cl([null, undefined, 3, 'class1', 'class2']); // Output ==> "3 class1 class2"
```

### Arguments as an object

`Note that the key is used as the class if its value is truthy`

```javascript
classList({class1: true, class2 : false}); // Output ==> "class1"
cl({ class1: true, class2: false }); // Output ==> "class1"

classList({class1: undefined, class2 : null, class3: true, class4: false}); // Output ==> "class3"
cl({ class1: undefined, class2: null, class3: true, class4: false }); // Output ==> "class3"
```

Note that the function **must** return a boolean.

```javascript
classList({
class1: function() { return false; },
class2 : function() { return true; }
cl({
class1: function () {
return false;
},
class2: function () {
return true;
},
});

// Output ==> "class2"
```

### Hybrid Arguments
### Mixed Arguments Types

```javascript
classList('class1', 'class2', 2, null, undefined, ['class3', null, undefined, 4, 'class4'], {
class5 : function() { return false; },
class6 : function() { return true; },
class7: undefined,
class8: true,
class9: false
cl('class1', 'class2', 2, null, undefined, ['class3', null, undefined, 4, 'class4'], {
class5: function () {
return false;
},
class6: function () {
return true;
},
class7: undefined,
class8: true,
class9: false,
});

// Output ==> "class1 class2 2 class3 4 class4 class6 class8"
```

## License

MIT © [tusharf5](https://github.com/tusharf5)
10 changes: 10 additions & 0 deletions coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1631445301264" clover="3.2.0">
<project timestamp="1631445301264" name="All files">
<metrics statements="1" coveredstatements="1" conditionals="23" coveredconditionals="23" methods="8" coveredmethods="8" elements="32" coveredelements="32" complexity="0" loc="1" ncloc="1" packages="1" files="1" classes="1"/>
<file name="index.cjs.js" path="/Users/tusharf5/dev/github/oss/dynamic-class-list/dist/index.cjs.js">
<metrics statements="1" coveredstatements="1" conditionals="23" coveredconditionals="23" methods="8" coveredmethods="8"/>
<line num="1" count="39" type="cond" truecount="23" falsecount="0"/>
</file>
</project>
</coverage>
2 changes: 2 additions & 0 deletions coverage/coverage-final.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"/Users/tusharf5/dev/github/oss/dynamic-class-list/dist/index.cjs.js": {"path":"/Users/tusharf5/dev/github/oss/dynamic-class-list/dist/index.cjs.js","statementMap":{"0":{"start":{"line":1,"column":27},"end":{"line":1,"column":53}},"1":{"start":{"line":1,"column":70},"end":{"line":1,"column":214}},"2":{"start":{"line":1,"column":112},"end":{"line":1,"column":116}},"3":{"start":{"line":1,"column":117},"end":{"line":1,"column":211}},"4":{"start":{"line":1,"column":154},"end":{"line":1,"column":190}},"5":{"start":{"line":1,"column":158},"end":{"line":1,"column":179}},"6":{"start":{"line":1,"column":231},"end":{"line":1,"column":287}},"7":{"start":{"line":1,"column":260},"end":{"line":1,"column":264}},"8":{"start":{"line":1,"column":265},"end":{"line":1,"column":284}},"9":{"start":{"line":1,"column":301},"end":{"line":1,"column":359}},"10":{"start":{"line":1,"column":311},"end":{"line":1,"column":313}},"11":{"start":{"line":1,"column":316},"end":{"line":1,"column":317}},"12":{"start":{"line":1,"column":341},"end":{"line":1,"column":359}},"13":{"start":{"line":1,"column":365},"end":{"line":1,"column":367}},"14":{"start":{"line":1,"column":370},"end":{"line":1,"column":407}},"15":{"start":{"line":1,"column":408},"end":{"line":1,"column":599}},"16":{"start":{"line":1,"column":438},"end":{"line":1,"column":563}},"17":{"start":{"line":1,"column":600},"end":{"line":1,"column":655}},"18":{"start":{"line":1,"column":661},"end":{"line":1,"column":662}},"19":{"start":{"line":1,"column":665},"end":{"line":1,"column":666}},"20":{"start":{"line":1,"column":667},"end":{"line":1,"column":724}}},"fnMap":{"0":{"name":"t","decl":{"start":{"line":1,"column":22},"end":{"line":1,"column":23}},"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":54}},"line":1},"1":{"name":"r","decl":{"start":{"line":1,"column":63},"end":{"line":1,"column":64}},"loc":{"start":{"line":1,"column":69},"end":{"line":1,"column":215}},"line":1},"2":{"name":"(anonymous_2)","decl":{"start":{"line":1,"column":94},"end":{"line":1,"column":95}},"loc":{"start":{"line":1,"column":105},"end":{"line":1,"column":212}},"line":1},"3":{"name":"(anonymous_3)","decl":{"start":{"line":1,"column":138},"end":{"line":1,"column":139}},"loc":{"start":{"line":1,"column":153},"end":{"line":1,"column":191}},"line":1},"4":{"name":"e","decl":{"start":{"line":1,"column":224},"end":{"line":1,"column":225}},"loc":{"start":{"line":1,"column":230},"end":{"line":1,"column":288}},"line":1},"5":{"name":"(anonymous_5)","decl":{"start":{"line":1,"column":242},"end":{"line":1,"column":243}},"loc":{"start":{"line":1,"column":253},"end":{"line":1,"column":285}},"line":1},"6":{"name":"n","decl":{"start":{"line":1,"column":297},"end":{"line":1,"column":298}},"loc":{"start":{"line":1,"column":300},"end":{"line":1,"column":600}},"line":1},"7":{"name":"(anonymous_7)","decl":{"start":{"line":1,"column":426},"end":{"line":1,"column":427}},"loc":{"start":{"line":1,"column":437},"end":{"line":1,"column":564}},"line":1}},"branchMap":{"0":{"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":53}},"type":"binary-expr","locations":[{"start":{"line":1,"column":34},"end":{"line":1,"column":41}},{"start":{"line":1,"column":43},"end":{"line":1,"column":53}}],"line":1},"1":{"loc":{"start":{"line":1,"column":117},"end":{"line":1,"column":211}},"type":"cond-expr","locations":[{"start":{"line":1,"column":138},"end":{"line":1,"column":198}},{"start":{"line":1,"column":199},"end":{"line":1,"column":211}}],"line":1},"2":{"loc":{"start":{"line":1,"column":158},"end":{"line":1,"column":179}},"type":"binary-expr","locations":[{"start":{"line":1,"column":158},"end":{"line":1,"column":161}},{"start":{"line":1,"column":163},"end":{"line":1,"column":179}}],"line":1},"3":{"loc":{"start":{"line":1,"column":199},"end":{"line":1,"column":211}},"type":"binary-expr","locations":[{"start":{"line":1,"column":199},"end":{"line":1,"column":200}},{"start":{"line":1,"column":202},"end":{"line":1,"column":211}}],"line":1},"4":{"loc":{"start":{"line":1,"column":265},"end":{"line":1,"column":284}},"type":"binary-expr","locations":[{"start":{"line":1,"column":265},"end":{"line":1,"column":273}},{"start":{"line":1,"column":275},"end":{"line":1,"column":284}}],"line":1},"5":{"loc":{"start":{"line":1,"column":438},"end":{"line":1,"column":563}},"type":"binary-expr","locations":[{"start":{"line":1,"column":438},"end":{"line":1,"column":442}},{"start":{"line":1,"column":445},"end":{"line":1,"column":562}}],"line":1},"6":{"loc":{"start":{"line":1,"column":445},"end":{"line":1,"column":562}},"type":"cond-expr","locations":[{"start":{"line":1,"column":484},"end":{"line":1,"column":508}},{"start":{"line":1,"column":509},"end":{"line":1,"column":562}}],"line":1},"7":{"loc":{"start":{"line":1,"column":445},"end":{"line":1,"column":483}},"type":"binary-expr","locations":[{"start":{"line":1,"column":445},"end":{"line":1,"column":463}},{"start":{"line":1,"column":465},"end":{"line":1,"column":483}}],"line":1},"8":{"loc":{"start":{"line":1,"column":509},"end":{"line":1,"column":562}},"type":"cond-expr","locations":[{"start":{"line":1,"column":526},"end":{"line":1,"column":532}},{"start":{"line":1,"column":533},"end":{"line":1,"column":562}}],"line":1},"9":{"loc":{"start":{"line":1,"column":533},"end":{"line":1,"column":562}},"type":"binary-expr","locations":[{"start":{"line":1,"column":533},"end":{"line":1,"column":534}},{"start":{"line":1,"column":536},"end":{"line":1,"column":554}},{"start":{"line":1,"column":556},"end":{"line":1,"column":562}}],"line":1},"10":{"loc":{"start":{"line":1,"column":567},"end":{"line":1,"column":599}},"type":"cond-expr","locations":[{"start":{"line":1,"column":578},"end":{"line":1,"column":596}},{"start":{"line":1,"column":597},"end":{"line":1,"column":599}}],"line":1}},"s":{"0":39,"1":11,"2":31,"3":31,"4":10,"5":10,"6":4,"7":14,"8":14,"9":24,"10":24,"11":24,"12":39,"13":24,"14":24,"15":24,"16":39,"17":1,"18":1,"19":1,"20":1},"f":{"0":39,"1":11,"2":31,"3":10,"4":4,"5":14,"6":24,"7":39},"b":{"0":[39,31],"1":[10,21],"2":[10,2],"3":[21,12],"4":[14,8],"5":[39,31],"6":[16,15],"7":[31,25],"8":[4,11],"9":[11,11,11],"10":[16,8]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"d10b0e8a194d94b0b652a35ce57de1b485b45c63"}
}
Loading

0 comments on commit 791b2e5

Please sign in to comment.