Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@a-la/markers

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@a-la/markers

A set of service markers used by alamode, e.g., to cut and paste comments.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@a-la/markers

npm version

@a-la/markers is a set of service markers used by alamode, e.g., to cut and paste comments.

yarn add -E @a-la/markers

Table Of Contents

API

The package is available by importing its default function:

import makeRules from '@a-la/markers'

makeRules(
  rules?: Rule[],
): void

This function will surround the rules with cut and paste rules for markers, to exclude from transforms:

  • strings
  • template literals
  • block comments
  • inline comments
/* yarn example/ */
import makeRules from '@a-la/markers'

const { rules, markers } = makeRules([
  {
    re: 'ALAMODE_RULE',
    replacement(match) {
      return match
    },
  },
])

console.log('\nRules:')
console.log(rules)

console.log('\nMarkers:')
console.log(markers)
Rules:
[ { re: /\/\*(?:[\s\S]+?)\*\//g,
    replacement: [Function: replacement] },
  { re: /\/\/(.+)/gm, replacement: [Function: replacement] },
  { re: /`[\s\S]+?`/gm, replacement: [Function: replacement] },
  { re: /(["'])(.*?)\1/gm, replacement: [Function: replacement] },
  { re: 'ALAMODE_RULE', replacement: [Function: replacement] },
  { re: /%%_RESTREAM_STRINGS_REPLACEMENT_(\d+)_%%/g,
    replacement: [Function: replacement] },
  { re: /%%_RESTREAM_LITERALS_REPLACEMENT_(\d+)_%%/g,
    replacement: [Function: replacement] },
  { re: /%%_RESTREAM_INLINECOMMENTS_REPLACEMENT_(\d+)_%%/g,
    replacement: [Function: replacement] },
  { re: /%%_RESTREAM_COMMENTS_REPLACEMENT_(\d+)_%%/g,
    replacement: [Function: replacement] } ]

Markers:
{ literals: 
   { name: 'literals',
     re: /`[\s\S]+?`/gm,
     regExp: /%%_RESTREAM_LITERALS_REPLACEMENT_(\d+)_%%/g,
     getReplacement: [Function: getDefaultReplacement],
     map: {},
     lastIndex: 0 },
  strings: 
   { name: 'strings',
     re: /(["'])(.*?)\1/gm,
     regExp: /%%_RESTREAM_STRINGS_REPLACEMENT_(\d+)_%%/g,
     getReplacement: [Function: getDefaultReplacement],
     map: {},
     lastIndex: 0 },
  comments: 
   { name: 'comments',
     re: /\/\*(?:[\s\S]+?)\*\//g,
     regExp: /%%_RESTREAM_COMMENTS_REPLACEMENT_(\d+)_%%/g,
     getReplacement: [Function: getDefaultReplacement],
     map: {},
     lastIndex: 0 },
  inlineComments: 
   { name: 'inlineComments',
     re: /\/\/(.+)/gm,
     regExp: /%%_RESTREAM_INLINECOMMENTS_REPLACEMENT_(\d+)_%%/g,
     getReplacement: [Function: getDefaultReplacement],
     map: {},
     lastIndex: 0 } }

TODO

  • Use negative lookahead in the strings regex to allow for escaping.

(c) À La Mode 2018

Keywords

FAQs

Package last updated on 01 Sep 2018

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