Socket
Socket
Sign inDemoInstall

sntls

Package Overview
Dependencies
2
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sntls

Essential data structures and behaviors


Version published
Weekly downloads
14
Maintainers
1
Install size
249 kB
Created
Weekly downloads
 

Readme

Source

Sntls

Pronounced: "Essentials"

A collection of general purpose classes and behaviors (class traits) such as collections, dictionaries, trees, ordered lists, etc. The purpose of Sntls is to turn routines performed on multitudes (of data entries or class instances) into a series of linear transformations, akin to the CQS style of jQuery. The goal of Sntls is to make such complex transformations easy to follow and modify.

Wiki

Reference

Npm package

Examples

JSFiddle

Splitting multiple strings at once

sntls.Collection.of(String).create(['foo', 'bar'])
    .split('')
    .items // [['f', 'o', 'o'], ['b', 'a', 'r']]

Queries

var whoKnowsWho = {
    "Joe": { knows: ["Al", "David", "Joan"] },
    "Al": { knows: ["Joe"] },
    "Joan": { knows: ["Joe", "Daniel", "Pam"] }
};

// first-degree connections of persons with names like "J..."
sntls.Collection.create(whoKnowsWho)
    // filtering items where keys start with "J"
    .filterByPrefix('J')
    // re-interpreting as Tree
    .toTree()
    // querying 'knows' nodes
    .queryPathValuePairsAsHash('|>knows'.toQuery())
    // and interpreting results as collection of arrays
    .toCollection(sntls.Collection.of(Array))
    .join(' and ') // joining all items
    // forming sentences
    .mapValues(function (item, path) {
        return path.toPath().asArray[0] + " knows " + item;
    })
    .getValues()

    // [
    //  "Joe knows Al and David and Joan",
    //  "Joan knows Joe and Daniel and Pam"
    // ]

Keywords

FAQs

Last updated on 08 May 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc