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

atom-selectors-plus

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atom-selectors-plus

An Atom selectors.js based selector utility with extra features

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

atom-selectors-plus

An Atom selector library based on Atom's selectors.js script with extra features :muscle: :point_left:

Features

:white_check_mark: Added functionality to validate Atom's ScopeSelector as ScopeSelector

By default Atom's selectors.js selectorMatchesAnyScope(selector, scopes) validates only individual scopes. Eg. .source.js or .string.quoted. For instance .source.js and .string.quoted are evaluated independently. Hence, nested selectors like .source.js .string evaluate to false which is a bit missleading if you expect to evaluate ScopeSelector included * selector.

Following is a comparison between improved selectorMatchesAnyScope(selector, scopes, useCache) and selectorMatchesAllScopes(selector, scopes, useCache) functions:

ScopeChain => .source.js .string.quoted.template
scopes     => [source.js,string.quoted.template]
============================================================
Testing anySelectorMatchAnyScope(selectors, scopes, useCache) function 

selector: [*, .text.plain]                                      => true
selector: [.source, .text.plain]                                => true
selector: [.source.js, .text.plain]                             => true
selector: [.string.quoted, .text.plain]                         => true
selector: [.source.js .string.quoted, .text.plain]              => true
selector: [.xml.source .string.quoted.template, .text.plain]    => true
selector: [.source .number, .text.plain]                        => true
selector: [.source.js .number, .text.plain]                     => true
selector: [.source.js .number, .text.plain, .source.js .string] => true
============================================================
Testing anySelectorMatchAllScopes(selectors, scopes, useCache) function 

selector: [*, .text.plain]                                      => true
selector: [.source, .text.plain]                                => true
selector: [.source.js, .text.plain]                             => true
selector: [.string.quoted, .text.plain]                         => true
selector: [.source.js .string.quoted, .text.plain]              => true
selector: [.xml.source .string.quoted.template, .text.plain]    => false # False as it's not a valid class selector for ScopeChain
selector: [.source .number, .text.plain]                        => false # False as it's not a valid class selector for ScopeChain
selector: [.source.js .number, .text.plain]                     => false # False as it's not a valid class selector for ScopeChain
selector: [.source.js .number, .text.plain, .source.js .string] => true
============================================================  

:white_check_mark: Added anySelectorMatchAnyScope(selectors, scopes, useCache) and anySelectorMatchAllScopes(selectors, scopes, useCache) functions to suport comma-separated (,) selector groups for matching testing of the form: .source.js .string.quoted, .text.xml .string.quoted.

Following is a comparison between added anySelectorMatchAnyScope(selectors, scopes, useCache) and anySelectorMatchAllScopes(selectors, scopes, useCache) functions:

Testing selectorMatchesAnyScope(selectors, scopes, useCache) VS selectorMatchesAllScopes(selectors, scopes, useCache)
============================================================
scopeChain => '.source.js'
selector   => '.source.js .string.quoted'

selectorMatchesAnyScope(selector, scopeChain)   => true  // '.source.js' token matches scope chain
selectorMatchesAllScopes(selector, scopeChain)  => false // No selector matches any scope. '.source.js .string.quoted selector' is more

Testing selectorMatchesAnyScope VS selectorMatchesAllScopes
============================================================
scopeChain => '.source.js'
selector   => '.source.js .string.quoted, .text.plain';

anySelectorMatchAnyScope(selector, scopeChain)   => true  // '.source.js' token matches scope chain 
anySelectorMatchAllScopes(selector, scopeChain)  => false // No selector matches any scope. '.source.js .string.quoted selector' is more specifyc)

:white_check_mark: Added cache to improve performance on high-demand match operations.

Cache feature is a modified version of great atom/autocomplete-plus's scope-helpers.js :100: that allows to use cache namespaces.

Cache is enabled by default by not passing useCache argument. To disable cache, pass useCache argument as false.

{
  "mAny": {
    ".source.js .string.quoted": {
      ".source.js": true
    },
    ".source.js": {
      ".source.js": true
    },
    ".string.quoted": {
      ".source.js": false
    },
    ".text.plain": {
      ".source.js": false
    }
  },
  "mAll": {
    ".source.js .string.quoted": {
      ".source.js": false
    },
    ".text.plain": {
      ".source.js": false
    }
  }
}

:white_check_mark: Removed dependency with underscore-plus's isSubset() function implemented in the script as:

  function isSubset(subset, superset) {
    return (Array.isArray(subset) && Array.isArray(superset)) &&
            subset
            .filter(sub => superset.includes(sub))
            .length === subset.length;
  }

Keywords

atom

FAQs

Package last updated on 08 Oct 2019

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