{"id":20348982,"url":"https://github.com/here-be/snapdragon-stack","last_synced_at":"2025-08-03T22:40:20.292Z","repository":{"id":57364569,"uuid":"116638392","full_name":"here-be/snapdragon-stack","owner":"here-be","description":"Snapdragon utility for creating a stack.","archived":false,"fork":false,"pushed_at":"2018-01-21T21:41:36.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T21:07:09.337Z","etag":null,"topics":["array","nodes","parse","parser","snapdragon","stack","tokenize","tokens"],"latest_commit_sha":null,"homepage":"https://github.com/here-be","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/here-be.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-08T06:24:54.000Z","updated_at":"2018-12-12T10:02:28.000Z","dependencies_parsed_at":"2022-09-13T21:11:25.458Z","dependency_job_id":null,"html_url":"https://github.com/here-be/snapdragon-stack","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/here-be","download_url":"https://codeload.github.com/here-be/snapdragon-stack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248502069,"owners_count":21114733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","nodes","parse","parser","snapdragon","stack","tokenize","tokens"],"created_at":"2024-11-14T22:23:31.851Z","updated_at":"2025-04-12T01:22:32.485Z","avatar_url":"https://github.com/here-be.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# snapdragon-stack [![NPM version](https://img.shields.io/npm/v/snapdragon-stack.svg?style=flat)](https://www.npmjs.com/package/snapdragon-stack) [![NPM monthly downloads](https://img.shields.io/npm/dm/snapdragon-stack.svg?style=flat)](https://npmjs.org/package/snapdragon-stack) [![NPM total downloads](https://img.shields.io/npm/dt/snapdragon-stack.svg?style=flat)](https://npmjs.org/package/snapdragon-stack) [![Linux Build Status](https://img.shields.io/travis/here-be/snapdragon-stack.svg?style=flat\u0026label=Travis)](https://travis-ci.org/here-be/snapdragon-stack)\n\n\u003e Snapdragon utility for creating a stack.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save snapdragon-stack\n```\n\n## Usage\n\n```js\nconst Stack = require('snapdragon-stack');\n```\n\n## API\n\n### [.first](index.js#L26)\n\nGet the first element in the stack.\n\n* `returns` **{any}**\n\n**Example**\n\n```js\nconst Stack = require('snapdragon-stack');\nstack.push('a');\nstack.push('b');\nstack.push('c');\nconsole.log(stack.first()); //=\u003e 'a'\n```\n\n### [.lookbehind](index.js#L49)\n\nGet the `n`th element from the end of the stack.\n\n**Params**\n\n* `n` **{Number}**\n* `returns` **{Object}**\n\n**Example**\n\n```js\nconst stack = new Stack();\nstack.push('aaa');\nstack.push('bbb');\nstack.push('ccc');\nstack.push('ddd');\nconsole.log(stack.lookbehind(1)); //=\u003e 'ddd'\nconsole.log(stack.lookbehind(2)); //=\u003e 'ccc'\nconsole.log(stack.lookbehind(3)); //=\u003e 'bbb'\n```\n\n### [.last](index.js#L69)\n\nGet the last element in the stack.\n\n* `returns` **{any}**\n\n**Example**\n\n```js\nconst Stack = require('snapdragon-stack');\nstack.push('a');\nstack.push('b');\nstack.push('c');\nconsole.log(stack.last()); //=\u003e 'c'\n```\n\n### [.current](index.js#L86)\n\nSemantic alias for `stack.last()`.\n\n* `returns` **{any}**\n\n**Example**\n\n```js\nconst Stack = require('snapdragon-stack');\nstack.push({ type: 'root' });\nconsole.log(stack.current()); //=\u003e { type: 'root' }\n```\n\n### [.prev](index.js#L105)\n\nGet the second-to-last item in the stack.\n\n* `returns` **{any}**\n\n**Example**\n\n```js\nconst Stack = require('snapdragon-stack');\nstack.push('a');\nstack.push('b');\nstack.push('c');\nconsole.log(stack.prev()); //=\u003e 'b'\n```\n\n### [.firstChild](index.js#L130)\n\nIf the [.first](#first) element in the stack is an object with a `.nodes` array, the first item from `stack.first().nodes` is returned.\n\n* `returns` **{any}**\n\n**Example**\n\n```js\nconst Stack = require('snapdragon-stack');\nconst Node = require('snapdragon-node');\n\nconst node = new Node({ type: 'brace' });\nnode.push(new Node({ type: 'brace.open', value: '{' }));\nnode.push(new Node({ type: 'text', value: 'a,b,c' }));\nnode.push(new Node({ type: 'brace.close', value: '}' }));\n\nstack.push(node);\nconsole.log(stack.firstChild()); //=\u003e Node { type: 'brace.open', value: '{' }\n```\n\n### [.lastChild](index.js#L158)\n\nIf the [.last](#last) element in the stack is an object with a `.nodes` array, the last item from `last.nodes` is returned.\n\n* `returns` **{any}**\n\n**Example**\n\n```js\nconst Stack = require('snapdragon-stack');\nconst Node = require('snapdragon-node');\n\nconst node = new Node({ type: 'brace' });\nnode.push(new Node({ type: 'brace.open', value: '{' }));\nnode.push(new Node({ type: 'text', value: 'a,b,c' }));\nnode.push(new Node({ type: 'brace.close', value: '}' }));\n\nstack.push(node);\nconsole.log(stack.lastChild()); //=\u003e Node { type: 'brace.close', value: '}' }\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning 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:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Author\n\n**Jon Schlinkert**\n\n* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on January 21, 2018._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhere-be%2Fsnapdragon-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhere-be%2Fsnapdragon-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhere-be%2Fsnapdragon-stack/lists"}