New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@diplodoc/utils

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diplodoc/utils

Diplodoc cross-packages utils

  • 1.1.0-beta
  • npm
  • Socket score

Version published
Weekly downloads
878
decreased by-52.9%
Maintainers
0
Weekly downloads
 
Created
Source

Diplodoc utils

NPM version

Diplodoc cross-packages utils.

Motivation

The Diplodoc ecosystem consists of many packages that have similar problems and needs. This package will contain all the general logic that is duplicated in our code base.

Table of contents

  • AttrsParser
  • [Extension Load Queue](#Extension Load Queue)

AttrsParser

Purpose

Support markdown-it-attrs-like attributes parser. Used in custom Diplodoc MarkdownIt plugins to add classes and anchors, enabling subsequent customization through CSS.

Interface

/* 
    optional first query
    if provided parser will parse it immediately
    each 'parse' call is pure
*/
const attrs = new AttrsParser('{.class #id data-name=diplodoc}');

attrs.state /* { class: ['class'], id: ['id'], 'data-name': ['diplodoc'] } */

const other = attrs.parse('{data-wide title="Support quotes too"}')

other /* { attr: ['data-wide'], title: ['Support quotes too'] } */

Extension Load Queue

Purpose

This queue mechanism allows asynchronous loading of extensions by setting a property on the "window" object in the browser. This property has a Symbol data type, which makes it difficult for external manipulations to access it.

Interface

// create a unique symbol
export const GLOBAL_SYMBOL: unique symbol = Symbol.for('someController');

// get the store
const store = getScriptStore<SomeController>(GLOBAL_SYMBOL);

// get the controller
const controller = useController<SomeController>(store);

See example in diplodoc-platform/html-extension

Keywords

FAQs

Package last updated on 01 Oct 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc