Skip to content

Commit b366792

Browse files
Merge pull request #26 from naman03malhotra/dwl-count
[Patch] Add more badges in readme file, add code of conduct, trigger workflow for forked PRs [v1.3.6]
2 parents c29bad6 + 66e3970 commit b366792

File tree

5 files changed

+103
-8
lines changed

5 files changed

+103
-8
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches-ignore:
66
- master
77

8+
pull_request_target:
9+
branches-ignore:
10+
- master
11+
812
jobs:
913
test:
1014
name: Test on node ${{ matrix.node }} and ${{ matrix.os }}
@@ -14,8 +18,8 @@ jobs:
1418
strategy:
1519
fail-fast: false
1620
matrix:
17-
node: [10, 12]
18-
os: [ubuntu-latest, macOS-latest]
21+
node: [10, 12, 15]
22+
os: [ubuntu-latest]
1923

2024
steps:
2125
- uses: actions/checkout@v1

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at naman03malhotra@gmail.com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ _**I wrote a [detailed blog post](https://dev.to/naman03malhotra/declaring-your-
99
### Install
1010

1111
[![Build Status](https://github.com/naman03malhotra/match-rules/workflows/CI/badge.svg?branch=master)](https://github.com/naman03malhotra/match-rules/actions)
12-
1312
[![Build Status](https://github.com/naman03malhotra/match-rules/workflows/CD/badge.svg?branch=master)](https://github.com/naman03malhotra/match-rules/actions)
14-
1513
[![Coverage Status](https://coveralls.io/repos/github/naman03malhotra/match-rules/badge.svg?branch=master&kill_cache=1)](https://coveralls.io/github/naman03malhotra/match-rules?branch=master&kill_cache=1)
14+
[![npm](https://img.shields.io/npm/dm/match-rules)](https://www.npmjs.com/package/match-rules)
15+
![npm](https://img.shields.io/npm/dt/match-rules)
16+
![NPM](https://img.shields.io/npm/l/match-rules)
17+
[![npm](https://img.shields.io/npm/v/match-rules)](https://www.npmjs.com/package/match-rules)
18+
[![DeepScan grade](https://deepscan.io/api/teams/11791/projects/14725/branches/280135/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=11791&pid=14725&bid=280135)
1619

1720
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/match-rules?label=GZipped&style=for-the-badge)](https://bundlephobia.com/result?p=match-rules)
1821

19-
<!-- [![npm](https://img.shields.io/npm/dm/match-rules)](https://www.npmjs.com/package/match-rules) -->
20-
2122
Through Yarn
2223
`yarn add match-rules`
2324

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "match-rules",
3-
"version": "1.3.5",
3+
"version": "1.3.6",
44
"description": "A tiny (1kB GZipped) zero dependency JavaScript utility that lets you write your conditional business logic in a declarative way (React like).",
55
"main": "lib/match_rules.js",
66
"repository": {

tests/match_rules.spec.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ describe("Test matchRules", () => {
3030

3131
const RULE_WITH_FUNCTION = {
3232
user_profile: {
33-
age: (value) => value > 18 && value < 50,
33+
age: (value, sourceObject) =>
34+
(value > 18 && value < 50 && sourceObject.country === "USA") ||
35+
sourceObject.show_ads === true,
3436
},
3537
};
3638

@@ -67,6 +69,7 @@ describe("Test matchRules", () => {
6769
can_send: true,
6870
can_delete: false,
6971
},
72+
country: "USA",
7073
};
7174

7275
beforeEach(() => {
@@ -190,6 +193,17 @@ describe("Test matchRules", () => {
190193
expect(matchRules(mainSource, RULE_WITH_FUNCTION)).toBe(true);
191194
});
192195

196+
it("should execute the function with two parameters first being the key's value and second being the original source object", () => {
197+
const spyFn = jest.spyOn(RULE_WITH_FUNCTION.user_profile, "age");
198+
199+
const result = matchRules(mainSource, RULE_WITH_FUNCTION);
200+
expect(spyFn).toBeCalledTimes(1);
201+
expect(spyFn).toBeCalledWith(mainSource.user_profile.age, mainSource);
202+
expect(result).toBe(true);
203+
204+
spyFn.mockRestore();
205+
});
206+
193207
it("should do string matching when the rule has a string value", () => {
194208
expect(matchRules(mainSource, RULE_WITH_STRING)).toBe(true);
195209
});

0 commit comments

Comments
 (0)