
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
@bonniernews/json-autocomplete
Advanced tools
Completes incomplete JSON string with caching capabilites
A utility to incrementally build and complete JSON strings from potentially incomplete JSON append operations with caching capabilities.
You can install JSON Autocomplete via npm or Yarn:
# Using npm
npm install @bonniernews/json-autocomplete
# Using Yarn
yarn add @bonniernews/json-autocomplete
import { createJsonAutocomplete } from "@bonniernews/json-autocomplete";
// Create a new autocompleter instance
const autocompleter = createJsonAutocomplete();
// Append incomplete JSON fragments
const part1 = '{"name": "Alice", "age": 30';
const completed1 = autocompleter.append(part1);
console.log(completed1); // Outputs: {"name": "Alice", "age": 30}
const part2 = ', "address": {"street": "123 Main St';
const completed2 = autocompleter.append(part2);
console.log(completed2); // Outputs: {"name": "Alice", "age": 30, "address": {"street": "123 Main St"}}
const part3 = '", "city": "Wonderland"}}';
const completed3 = autocompleter.append(part3);
console.log(completed3); // Outputs: {"name": "Alice", "age": 30, "address": {"street": "123 Main St", "city": "Wonderland"}}
jsonAutocomplete
HelperFor simpler use cases, you can use the jsonAutocomplete
helper function which manages the autocompleter instance internally.
import { jsonAutocomplete } from "@bonniernews/json-autocomplete";
const incompleteJson1 = '{"isActive": true, "roles": ["admin", "user"';
const completedJson1 = jsonAutocomplete(incompleteJson1);
console.log(completedJson1); // Outputs: {"isActive": true, "roles": ["admin", "user"]}
const incompleteJson2 = ', "permissions": {"read": true, "write": false';
const completedJson2 = jsonAutocomplete(incompleteJson2);
console.log(completedJson2); // Outputs: {"isActive": true, "roles": ["admin", "user"], "permissions": {"read": true, "write": false}}
createJsonAutocomplete()
Creates a new JSON autocompleter instance.
An object with the following method:
append(part: string): string
: Appends a fragment of JSON and returns the best possible valid JSON string constructed from all appended fragments.import { createJsonAutocomplete } from "@bonniernews/json-autocomplete";
const autocompleter = createJsonAutocomplete();
const jsonPart1 = '{"product": "Laptop", "price": 1200';
const completedJson1 = autocompleter.append(jsonPart1);
console.log(completedJson1); // {"product": "Laptop", "price": 1200}
const jsonPart2 = ', "specs": {"cpu": "Intel i7", "ram": "16GB"';
const completedJson2 = autocompleter.append(jsonPart2);
console.log(completedJson2); // {"product": "Laptop", "price": 1200, "specs": {"cpu": "Intel i7", "ram": "16GB"}}
const jsonPart3 = "}}";
const completedJson3 = autocompleter.append(jsonPart3);
console.log(completedJson3); // {"product": "Laptop", "price": 1200, "specs": {"cpu": "Intel i7", "ram": "16GB"}}
jsonAutocomplete
A helper function to incrementally autocomplete a JSON string without manually managing the autocompleter instance.
incompleteJsonString: string
: The incomplete JSON string fragment.autocompleter?: ReturnType<typeof createJsonAutocomplete>
: (Optional) An existing autocompleter instance. If not provided, a new one is created.string
: The best possible valid JSON string constructed from all appended fragments.import { jsonAutocomplete } from "@bonniernews/json-autocomplete";
let completedJson = jsonAutocomplete('{"title": "Book"');
console.log(completedJson); // {"title": "Book"}
completedJson = jsonAutocomplete(', "author": "Jane Doe"');
console.log(completedJson); // {"title": "Book", "author": "Jane Doe"}
completedJson = jsonAutocomplete("}");
console.log(completedJson); // {"title": "Book", "author": "Jane Doe"}
Contributions are welcome! Please follow these steps:
Fork the repository: Click the Fork button at the top right of the repository page.
Clone your fork:
git clone https://github.com/your-username/json-autocomplete.git
cd json-autocomplete
Install dependencies:
npm install
Create a new branch:
git checkout -b feature/YourFeature
Make your changes: Implement your feature or bug fix.
Lint and type-check:
npm run lint
npm run typecheck
Run tests:
npm test
Commit your changes:
git commit -m "Add your message here"
Push to your fork:
git push origin feature/YourFeature
Create a Pull Request: Go to the original repository and submit a pull request.
Please adhere to the Bonnier News Code of Conduct in all your interactions with the project.
This project is licensed under the MIT License. You are free to use, modify, and distribute it as per the license terms.
If you encounter any issues or have questions, please open an issue on GitHub.
Note: This README assumes that the repository is hosted at
https://github.com/BonnierNews/json-autocomplete
. Please update the links accordingly if the repository is located elsewhere.
FAQs
Completes incomplete JSON string with caching capabilites
We found that @bonniernews/json-autocomplete demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.