Installations
npm install carrot-js
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.9.0
NPM Version
6.14.8
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
jofri
Download Statistics
Total Downloads
761
Last Day
1
Last Week
8
Last Month
13
Last Year
97
GitHub Statistics
1 Stars
5 Commits
1 Watching
1 Branches
1 Contributors
Bundle Size
10.74 kB
Minified
3.07 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.2
Package Id
carrot-js@1.0.2
Unpacked Size
7.00 kB
Size
3.41 kB
File Count
6
NPM Version
6.14.8
Node Version
14.9.0
Total Downloads
Cumulative downloads
Total Downloads
761
Last day
0%
1
Compared to previous day
Last week
166.7%
8
Compared to previous week
Last month
333.3%
13
Compared to previous month
Last year
-36.2%
97
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Carrot-js - Like Redux without the boilerplate
- No more props! - Store and retrieve variables from any React file without passing down props
- Reactive variables! - Listen for changes to instantly update your state (or activate your callback)
- Easy peasy carrot squeezy! - Just import carrot-js in any file and you're ready to go
Â
Example
Install Carrot-js using your terminal:
1npm install carrot-js
Import Carrot-js in your root-component (usually App.js) and wrap all your components:
1import { Carrot, pantry } from 'carrot-js'; 2 3function App() { 4 return ( 5 <> 6 <Carrot value={pantry}> 7 <Navbar /> 8 <Dashboard /> 9 </Carrot> 10 <> 11 ); 12}
Set variable
'Plant' a variable from any file (eg. an API response). Your plant method takes 2 arguments:
- Variable name
- Data to be stored in variable
1import { plant } from 'carrot-js'; 2 3plant('exampleVariable', 'Crops are good this year!');
Get variable ( and listen for any future variable changes)
The 'pick' method will get your variable and start listening for any changes to it. It takes two arguments:
- Variable name
- Callback function (eg. setVariable, myFunction, (data) => { console.log(data) } etc.)
Every time the variable changes, 'pick' will execute your callback function. The component below will print 'Crops are good this year!':
1import { useEffect, useState } from 'react'; 2import { pick } from 'carrot-js'; 3 4function MyComponent () { 5 const [variable, setVariable] = useState(''); 6 7 useEffect( () => { 8 pick('exampleVariable', setVariable); 9 }, []); 10 11 return ( 12 <> 13 <h4>{variable}</h4> 14 <> 15 ); 16}
Licence
MIT
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More