New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

input-proxy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

input-proxy

Removes some of the hassle when storing JSON in an input.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Input Proxy

Store JSON in an HTMLInputElement with less hassle

Reason

Forgetting to restringify your JSON into the input? Tired of writing the same function to unparse the JSON just for one value?

I sure did! So I wrapped my HTMLInputElement in a Proxy, and wrote some get and set methods to deal with just that.

Benefits

Pass in an HTMLInputElement, and then the value becomes a JSON object that you can access just be requesting the key.

Example

import { IP } from '../input-proxy.js';

const input = document.getElementById('StoresJSON');
const wrappedInput = IP(input);

wrappedInput.name = 'John'; //

wrappedInput.name; // 'John'

// Access the input values like so
input.value; // '{ "name": "John" }'
// or
wrappedInput.__value; // '{ "name": "John" }'

// If a key hasn't been set or is deleted,
// InputProxy returns null
delete wrappedInput.name;

wrappedInput.name; // null

WARNING

To prevent issues with JSON.stringify, on creation InputProxy sets the value of the element passed in to be '{}'.

FAQs

Package last updated on 05 Sep 2021

Did you know?

Socket

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.

Install

Related posts