jsbi
Sugar
jsbi | Sugar | |
---|---|---|
4 | 4 | |
892 | 4,524 | |
0.4% | - | |
2.0 | 0.0 | |
10 months ago | 6 months ago | |
JavaScript | JavaScript | |
Apache License 2.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
jsbi
-
How to Implement and Deploy a Smart Contract Event Listener with AWS CDK
import 'dotenv/config'; import * as erc20abi from './abi.json'; import Web3, { Contract, WebSocketProvider } from 'web3'; /* Workaround for JSON.stringify() event logs with BigInt values. We need to stringify event logs for more readable logging in CloudWatch. https://github.com/GoogleChromeLabs/jsbi/issues/30 */ (BigInt.prototype as any).toJSON = function () { return this.toString(); }; /** * Starts the smart contract event listener. * Websocket Provider config: https://docs.web3js.org/api/web3-providers-ws/class/WebSocketProvider * @param chain - Name of the blockchain network for logging purposes. * @param wssEndpoint - Websocket endpoint for the blockchain network. * @param contractAddress - Smart contract address. */ const startEventListener = async (chain: string, wssEndpoint: string, contractAddress: string) => { const provider = new WebSocketProvider( wssEndpoint, {}, { autoReconnect: true, delay: 10000, // Default: 5000 ms maxAttempts: 10, // Default: 5 }, ); provider.on('connect', () => { console.log(`Connected to ${chain} websocket provider`); }); provider.on('disconnect', error => { console.error(`Closed ${chain} webSocket connection`, error); }); const web3 = new Web3(provider); /* Smart contract event listeners Listening to events: - Transfer - Approval */ const contract = new web3.eth.Contract(erc20abi, contractAddress); await subscribeToEvent(chain, contract, 'Transfer'); await subscribeToEvent(chain, contract, 'Approval'); }; /** * Subscribes to a smart contract event. * @param chain - Name of the blockchain network for logging purposes. * @param contract - Smart contract address. * @param eventName - Name of the event to subscribe to. */ const subscribeToEvent = async (chain: string, contract: Contract, eventName: string) => { const subscription = await contract.events[eventName](); subscription.on('connected', subscriptionId => { console.log(`${chain} USDT '${eventName}' SubID:`, subscriptionId); }); subscription.on('data', event => { console.log(`${chain} USDT '${eventName}'`, JSON.stringify({ event })); // cannot json.stringify BigInt... }); subscription.on('changed', event => { // Remove event from local database }); subscription.on('error', error => { console.error(`${chain} USDT '${eventName}' error:`, error); }); }; /* Start smart contract event listeners Chains: - Ethereum */ startEventListener('Ethereum', process.env.ETH_WSS_ENDPOINT!, process.env.ETH_SMART_CONTRACT_ADDRESS!);
-
BigInt support for Android without Hermes
Have you considered something like https://github.com/GoogleChromeLabs/jsbi ? That's a pure-JS implementation of BigInt (though it may have some caveats for usage - check the repo for details).
-
TypeError: Cannot read property 'BigInt' of undefined
I looked at the repository: https://github.com/GoogleChromeLabs/jsbi
- Prisma returning this response when I try searching for a particular record or returning a single record
Sugar
-
Any bad experience with libraries such as date-fns.js or sugar.js (instead of moment.js) with Netsuite SuiteScript 2.X? (xposted from /r/Netsuite)
I've been meaning to use moment.js for a long time in Netsuite but instead always jimmied around with native javascript date functions. Finally getting around to doing some basic functions with moment.js in a couple of solutions, but non-Netsuite developers are telling me date-fns.js is more intuitive and lightweight than moment.js. Also there are other libraries like sugar.js with functions like "Date.create('last week Friday');" which look like it would be fun to use with N/query or N/search.
-
Sugar Coders
And ... it exists.
- Show HN: A simple time conversion site for developers
-
I want to build an NPM module to extend, array, string and object prototypes. Is it possible ?
If you want utility functions, check out github.com/andrewplummer/Sugar. If you want to write totally custom stuff, you can take it as a reference.
What are some alternatives?
core-js - Standard Library
lodash - A modern JavaScript utility library delivering modularity, performance, & extras.
polyfill - Set of all Javascript polyfills
underscore - JavaScript's utility _ belt
window.fetch polyfill - A window.fetch JavaScript polyfill.
lazy.js - Like Underscore, but lazier
Docker Swarm - Source repo for Docker's Documentation
rubico - [a]synchronous functional programming
aws-cdk - The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
ramda - :ram: Practical functional Javascript
history.js - History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.
scramjet - Public tracker for Scramjet Cloud Platform, a platform that bring data from many environments together.