npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

javascript-toolbox

v1.4.2

Published

Популярные операции для создания приложений

Downloads

8

Readme

Набор инструментов для использования в приложениях

Установка

$ npm install javascript-toolbox

Использование в браузере

Необходимо сделать serve для запросов к папке /javascript-toolbox -> ./node_modules/javascript-toolbox

<script type="importmap">
{
  "imports": {
    "javascript-toolbox": "/javascript-toolbox/index.js"
  }
}
</script>
import { UUID, Deferred, Locator, Screen, ... } 'javascript-toolbox';
...

Классы

UUID

import UUID from 'javascript-toolbox/library/UUID.js';
  • new UUID(value: string) - создает UUID из переданной строки
  • UUID.zero() - создает UUID из нулей
  • UUID.random(), new UUID() - создает случайный UUID
  • UUID.valudate(value: UUID | string) - проверяет на корректность записи
  • UUID.is(uuid: any): boolean - instanceof UUID
  • UUID.value - readonly:string - значение
  • UUID.compare(uuid: UUID): boolean

Deferred - отложенный объект

Promise-like объект, способный резолвиться извне

import Deferred from 'javascript-toolbox/library/Deferred.js';

const promise = new Deferred();
promise.resolve();
promise.reject();

Locator

Базовый класс для реализации DI паттерна ServiceLocator

locator.js

import Locator from 'javascript-toolbox/library/Locator.js';

export class AppLocator extends Locator {
  get service1() {
    return this.get('service1');
  }

  get service2() {
    return this.get('service2');
  }

  get service3() {
    return this.get('service3');
  }
}

const locator = new AppLocator();
export default locator;

index.js

import locator from './locator.js';

locator.services = { service1, service2 };
locator.set('service3', service3);

Screen - класс для получения инфы и работы с экраном юзера @browser

import Screen from 'javascript-toolbox/library/Scren.js'

const root = documemnt.body;
const screen = new Screen(root);

screen.observe(node, onResize); // onResize.call(node, screen);
screen.unObserve(node, onResize1, onResize2, ...);

screen.onResize(callback); // callback.call(root, screen);
screen.offResize(callback1, callback2, callback3, ...);

screen.width  // number
screen.height // number
screen.size   // javascript-algebra/Vector
screen.center // javascript-algebra/Vector

Screen.pointer(mouseEvent) // javascript-algebra/Vector
Screen.animation(render) // requestAnimationFrame

Gestures - работа с жестами (тачпад)

new Gestures(element)
  .start(_ => ({ scale, rotation })) // стартовые значения (position?)
  .translate(({ difference }) => scene.move(difference))
  .scale(({ scale }) => scene.scale(scale))
  .rotate(({ rotation }) => scene.rotate(rotation));

Context-Store API


const context = new Context("name", { data: 0 }, (initState) => { data: initState.data + 1 });

context.dispatch({ data: 2 })

context.on(() => {
  context.select(store => store.data); // 2
});