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

@web-companions/h

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web-companions/h

Helper functions for using with @web-companions

latest
Source
npmnpm
Version
0.3.3
Version published
Maintainers
1
Created
Source
Last npm Registry Version

@web-companions/h

A set of helper functions

  • Installation
  • Usage

Installation

npm install @web-companions/h --save

Usage

css

index.jsx

import { css } from '@web-companions/h';

<div>
  <span
    style={css`
      color: red;
    `}
  >
    Red text
  </span>
</div>

setStyle

index.jsx

import { setStyle } from '@web-companions/h';

// domNode is an Element or ShadowRoot
setStyle(require('./style.css'), domNode);

instantMapper

The easier and simples mapper for EG. It will update a component's property immediately without waiting other changes.

NOTE: Use it only if you want to maximal speed up you component.

! Pay attention that it's not possible to change several different properties inside one updating iteration with this mapper.

index.jsx

import { instantMapper } from '@web-companions/h';
import { EG } from '@web-companions/gfc';
import { render } from 'lit-html';

let sum = 0;

export const demoElement = EG(
  mapper: instantMapper
)(function* () {
  let state: number = 0;

  const setState = (newState: number) => {
    state = newState;

    this.next();
  };

  while (true) {
    if (state < 5) {
      setState(++sum);
    }

    yield render(<div>Sum Immediate - {String(state)}</div>, this);
  }
});

License

MIT

Keywords

helpers

FAQs

Package last updated on 24 May 2024

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