Socket
Socket
Sign inDemoInstall

snapdragon-node

Package Overview
Dependencies
13
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

24

index.js
'use strict';
var utils = require('snapdragon-util');
var define = require('define-property');
var isObject = require('isobject');
var getters = ['siblings', 'index', 'first', 'lext', 'prev', 'next'];
var utils = require('./utils');

@@ -25,3 +23,3 @@ /**

this.define('isNode', true);
if (isObject(val)) {
if (utils.isObject(val)) {
for (var key in val) {

@@ -53,3 +51,3 @@ if (getters.indexOf(key) === -1) {

define(name, val) {
define(this, name, val);
utils.define(this, name, val);
return this;

@@ -75,3 +73,3 @@ }

this.nodes = this.nodes || [];
define(node, 'parent', this);
utils.define(node, 'parent', this);
this.nodes.push(node);

@@ -107,3 +105,3 @@ }

this.nodes = this.nodes || [];
define(node, 'parent', this);
utils.define(node, 'parent', this);
this.nodes.unshift(node);

@@ -129,3 +127,3 @@ }

getNode(type) {
return utils.getNode(this.nodes, type);
return utils.su.getNode(this.nodes, type);
}

@@ -149,3 +147,3 @@

isType(type) {
return utils.isType(this, type);
return utils.su.isType(this, type);
}

@@ -172,3 +170,3 @@

hasType(type) {
return utils.hasType(this, type);
return utils.su.hasType(this, type);
}

@@ -296,3 +294,3 @@

get first() {
return utils.arrayify(this.nodes)[0];
return utils.su.arrayify(this.nodes)[0];
}

@@ -320,3 +318,3 @@

get last() {
return utils.last(utils.arrayify(this.nodes));
return utils.su.last(utils.su.arrayify(this.nodes));
}

@@ -326,5 +324,5 @@ };

/**
* Expose `Node`
* expose `Node`
*/
module.exports = Node;
{
"name": "snapdragon-node",
"description": "Snapdragon utility for creating a new AST node in custom code, such as plugins.",
"version": "1.0.1",
"version": "1.0.2",
"homepage": "https://github.com/jonschlinkert/snapdragon-node",

@@ -25,2 +25,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"isobject": "^3.0.0",
"lazy-cache": "^2.0.2",
"snapdragon-util": "^1.0.2"

@@ -27,0 +28,0 @@ },

@@ -52,3 +52,3 @@ # snapdragon-node [![NPM version](https://img.shields.io/npm/v/snapdragon-node.svg?style=flat)](https://www.npmjs.com/package/snapdragon-node) [![NPM monthly downloads](https://img.shields.io/npm/dm/snapdragon-node.svg?style=flat)](https://npmjs.org/package/snapdragon-node) [![NPM total downloads](https://img.shields.io/npm/dt/snapdragon-node.svg?style=flat)](https://npmjs.org/package/snapdragon-node) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/snapdragon-node.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/snapdragon-node)

### [Node](index.js#L22)
### [Node](index.js#L20)

@@ -70,3 +70,3 @@ Create a new AST `Node` with the given `val` and `type`.

### [.define](index.js#L51)
### [.define](index.js#L49)

@@ -88,3 +88,3 @@ Define a non-enumberable property on the node instance.

### [.pushNode](index.js#L71)
### [.pushNode](index.js#L69)

@@ -106,7 +106,7 @@ Given node `foo` and node `bar`, push node `bar` onto `foo.nodes`, and set `foo` as `bar.parent`.

### [.addNode](index.js#L83)
### [.addNode](index.js#L81)
Alias for [pushNode](#pushNode) for backwards compatibility with 0.1.0.
### [.unshiftNode](index.js#L102)
### [.unshiftNode](index.js#L100)

@@ -128,3 +128,3 @@ Given node `foo` and node `bar`, unshift node `bar` onto `foo.nodes`, and set `foo` as `bar.parent`.

### [.getNode](index.js#L124)
### [.getNode](index.js#L122)

@@ -147,3 +147,3 @@ Get the first child node from `node.nodes` that matches the given `type`. If `type` is a number, the child node at that index is returned.

### [.isType](index.js#L143)
### [.isType](index.js#L141)

@@ -166,3 +166,3 @@ Return true if the node is the given `type`.

### [.hasType](index.js#L165)
### [.hasType](index.js#L163)

@@ -188,3 +188,3 @@ Return true if the `node.nodes` has the given `type`.

### [.siblings](index.js#L187)
### [.siblings](index.js#L185)

@@ -208,3 +208,3 @@ Get the siblings array, or `null` if it doesn't exist.

### [.prev](index.js#L208)
### [.prev](index.js#L206)

@@ -227,3 +227,3 @@ Get the previous node from the siblings array or `null`.

### [.next](index.js#L232)
### [.next](index.js#L230)

@@ -247,3 +247,3 @@ Get the siblings array, or `null` if it doesn't exist.

### [.index](index.js#L260)
### [.index](index.js#L258)

@@ -270,3 +270,3 @@ Get the node's current index from `node.parent.nodes`. This should always be correct, even when the parent adds nodes.

### [.first](index.js#L288)
### [.first](index.js#L286)

@@ -291,3 +291,3 @@ Get the first node from `node.nodes`.

### [.last](index.js#L311)
### [.last](index.js#L309)

@@ -294,0 +294,0 @@ Get the last node from `node.nodes`.

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