Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
linkfunction
Advanced tools
Create an Event handler function that call a given function with input value.
npm install --save linkfunction
The UMD build is also available on unpkg:
<script src="//unpkg.com/linkfunction/dist/linkfunction.umd.js"></script>
This exposes the linkFunction()
function as a global.
It's important to understand what linkFunction does in order to use it comfortably.
linkFunction(fn, [valuePath])
fn
: the function that will called with value as parametervaluePath
: optional key/path into the event object at which to retrieve the new valueCheck the javascript vanilla usage:
const linkfunction = require('linkfunction')
const e = { // Will be your SyntheticEvent for input
target: {
nodeName: 'any',
type: 'text',
value: 'Riderman'
}
}
const setName = name => console.log(name) // Output Riderman
const handler = linkfunction(setName)
handler(e)
Here's two equivalent event handlers, one created manually and one created with linkFunction:
handleInput = e => {
myFn(e.target.value)
}
handleInput = linkFunction(myFn)
Notice how we didn't specify the event path - if omitted, linkFunction()
will use the checked
or value
property of the event target, based on its type.
Standard usage is a function that returns an event handler that call your given function witn input value.
import linkFunction from 'linkfunction';
class Foo extends Component {
setName(name) {
const { obj } = this.props;
obj.setName(name);
}
render({ obj }) {
return (
<input
value={obj.name}
onInput={linkFunction(this.setName)}
/>
);
}
}
The main reason is for supporting updates with mobx-state-tree models.
This lib will made easy update models with inputs
That example, will update any related component once input has changed.
First off, thanks for taking the time to contribute! Now, take a moment to be sure your contributions make sense to everyone else.
Found a problem? Want a new feature? First of all see if your issue or idea has already been reported. If it hasn't, just open a new clear and descriptive issue.
Pull requests are the greatest contributions, so be sure they are focused in scope, and do avoid unrelated commits.
💁 Remember: size is the #1 priority.
Every byte counts! PR's can't be merged if they increase the output size much.
git clone https://github.com/<your-username>/linkfunction
cd linkfunction
git checkout -b my-new-feature
npm install
npm run build
to verify your change doesn't increase output size.npm test
to make sure your change doesn't break anything.git commit -am 'Add some feature'
git push origin my-new-feature
This project was created based on linkstate.
The main reason to created another one was the dependencies. linkFunction has no dependency of framework or lib, just function that call another function.
However, I would like to thanks Jason Miller for the incredible project
FAQs
Link input value into function
The npm package linkfunction receives a total of 5 weekly downloads. As such, linkfunction popularity was classified as not popular.
We found that linkfunction demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.