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

mako-tree

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mako-tree - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

5

HISTORY.md
1.2.0 / 2016-10-08
==================
* feat(tree): implement Iterable interface
1.1.1 / 2016-10-03

@@ -3,0 +8,0 @@ ==================

@@ -31,2 +31,12 @@ 'use strict'

/**
* Implement the iterator interface to allow iterating the files in this
* tree topologically.
*
* TODO: allow configuring the iteration order (ie: turn topological off)
*/
[Symbol.iterator] () {
return this.getFiles({ topological: true }).values()
}
/**
* Checks to see if the given file ID exists in the tree.

@@ -33,0 +43,0 @@ *

2

package.json
{
"name": "mako-tree",
"version": "1.1.1",
"version": "1.2.0",
"main": "./lib/tree",

@@ -5,0 +5,0 @@ "description": "The build tree structure used internally by mako",

@@ -33,2 +33,16 @@ # mako-tree

### Tree[@@iterable]()
This class implements the `Iterable` interface, which iterates the files in the tree in topological
order. (see `Tree#getFiles()` for more information)
```js
for (const file of tree) {
// iterate files in topological order
}
```
This sugar allows you to treat the tree itself as an iterable, which can be useful in interacting
with other APIs.
### Tree#hasFile(file)

@@ -35,0 +49,0 @@

@@ -25,2 +25,32 @@ /* eslint-env mocha */

describe('@@iterator()', function () {
// index.html <- index.js <- shared.js
// <- index.css <- shared.css
let tree = new Tree()
let html = tree.addFile('index.html')
let js = tree.addFile('index.js')
let sharedJS = tree.addFile('shared.js')
let css = tree.addFile('index.css')
let sharedCSS = tree.addFile('shared.css')
tree.addDependency(html, js)
tree.addDependency(html, css)
tree.addDependency(js, sharedJS)
tree.addDependency(css, sharedCSS)
it('should implement the iterator interface', function () {
let count = 0
for (const file of tree) {
count += 1
assert.instanceOf(file, File)
}
assert.equal(count, 5)
})
it('should sort the items topologically', function () {
let files = []
for (const file of tree) files.push(file)
assert.deepEqual(files, [ sharedJS, sharedCSS, js, css, html ])
})
})
describe('#hasFile(id)', function () {

@@ -27,0 +57,0 @@ let tree = new Tree()

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