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

snapdragon-stack

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snapdragon-stack

Snapdragon utility for creating a stack.

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
increased by57240%
Maintainers
1
Weekly downloads
 
Created
Source

snapdragon-stack NPM version NPM monthly downloads NPM total downloads Linux Build Status

Snapdragon utility for creating a stack.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.

Install

Install with npm:

$ npm install --save snapdragon-stack

Usage

const Stack = require('snapdragon-stack');

API

.first

Get the first element in the stack.

  • returns {any}

Example

const Stack = require('snapdragon-stack');
stack.push('a');
stack.push('b');
stack.push('c');
console.log(stack.first()); //=> 'a'

.lookbehind

Get the nth element from the end of the stack.

Params

  • n {Number}
  • returns {Object}

Example

const stack = new Stack();
stack.push('aaa');
stack.push('bbb');
stack.push('ccc');
stack.push('ddd');
console.log(stack.lookbehind(1)); //=> 'ddd'
console.log(stack.lookbehind(2)); //=> 'ccc'
console.log(stack.lookbehind(3)); //=> 'bbb'

.last

Get the last element in the stack.

  • returns {any}

Example

const Stack = require('snapdragon-stack');
stack.push('a');
stack.push('b');
stack.push('c');
console.log(stack.last()); //=> 'c'

.current

Semantic alias for stack.last().

  • returns {any}

Example

const Stack = require('snapdragon-stack');
stack.push({ type: 'root' });
console.log(stack.current()); //=> { type: 'root' }

.prev

Get the second-to-last item in the stack.

  • returns {any}

Example

const Stack = require('snapdragon-stack');
stack.push('a');
stack.push('b');
stack.push('c');
console.log(stack.prev()); //=> 'b'

.firstChild

If the .first element in the stack is an object with a .nodes array, the first item from stack.first().nodes is returned.

  • returns {any}

Example

const Stack = require('snapdragon-stack');
const Node = require('snapdragon-node');

const node = new Node({ type: 'brace' });
node.push(new Node({ type: 'brace.open', value: '{' }));
node.push(new Node({ type: 'text', value: 'a,b,c' }));
node.push(new Node({ type: 'brace.close', value: '}' }));

stack.push(node);
console.log(stack.firstChild()); //=> Node { type: 'brace.open', value: '{' }

.lastChild

If the .last element in the stack is an object with a .nodes array, the last item from last.nodes is returned.

  • returns {any}

Example

const Stack = require('snapdragon-stack');
const Node = require('snapdragon-node');

const node = new Node({ type: 'brace' });
node.push(new Node({ type: 'brace.open', value: '{' }));
node.push(new Node({ type: 'text', value: 'a,b,c' }));
node.push(new Node({ type: 'brace.close', value: '}' }));

stack.push(node);
console.log(stack.lastChild()); //=> Node { type: 'brace.close', value: '}' }

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on January 21, 2018.

Keywords

FAQs

Package last updated on 21 Jan 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