cheerio Build Status Gittask

Fast, flexible, and lean implementation of core jQuery designed specifically for the server.

Introduction

Teach your server HTML.

  1. var cheerio = require('cheerio'),
  2. $ = cheerio.load('<h2 class="title">Hello world</h2>');
  3. $('h2.title').text('Hello there!');
  4. $('h2').addClass('welcome');
  5. $.html();
  6. //=> <h2 class="title welcome">Hello there!</h2>

Installation

npm install cheerio

Features

❤ Familiar syntax: Cheerio implements a subset of core jQuery. Cheerio removes all the DOM inconsistencies and browser cruft from the jQuery library, revealing its truly gorgeous API.

ϟ Blazingly fast: Cheerio works with a very simple, consistent DOM model. As a result parsing, manipulating, and rendering are incredibly efficient. Preliminary end-to-end benchmarks suggest that cheerio is about 8x faster than JSDOM.

❁ Incredibly flexible: Cheerio wraps around @FB55’s forgiving htmlparser2. Cheerio can parse nearly any HTML or XML document.

What about JSDOM?

I wrote cheerio because I found myself increasingly frustrated with JSDOM. For me, there were three main sticking points that I kept running into again and again:

• JSDOM’s built-in parser is too strict: JSDOM’s bundled HTML parser cannot handle many popular sites out there today.

• JSDOM is too slow: Parsing big websites with JSDOM has a noticeable delay.

• JSDOM feels too heavy: The goal of JSDOM is to provide an identical DOM environment as what we see in the browser. I never really needed all this, I just wanted a simple, familiar way to do HTML manipulation.

When I would use JSDOM

Cheerio will not solve all your problems. I would still use JSDOM if I needed to work in a browser-like environment on the server, particularly if I wanted to automate functional tests.

API

Markup example we’ll be using:

  1. <ul id="fruits">
  2. <li class="apple">Apple</li>
  3. <li class="orange">Orange</li>
  4. <li class="pear">Pear</li>
  5. </ul>

This is the HTML markup we will be using in all of the API examples.

Loading

First you need to load in the HTML. This step in jQuery is implicit, since jQuery operates on the one, baked-in DOM. With Cheerio, we need to pass in the HTML document.

This is the preferred method:

  1. var cheerio = require('cheerio'),
  2. $ = cheerio.load('<ul id="fruits">...</ul>');

Optionally, you can also load in the HTML by passing the string as the context:

  1. $ = require('cheerio');
  2. $('ul', '<ul id="fruits">...</ul>');

Or as the root:

  1. $ = require('cheerio');
  2. $('li', 'ul', '<ul id="fruits">...</ul>');

You can also pass an extra object to .load() if you need to modify any of the default parsing options:

  1. $ = cheerio.load('<ul id="fruits">...</ul>', {
  2. normalizeWhitespace: true,
  3. xmlMode: true
  4. });

These parsing options are taken directly from htmlparser2, therefore any options that can be used in htmlparser2 are valid in cheerio as well. The default options are:

  1. {
  2. normalizeWhitespace: false,
  3. xmlMode: false,
  4. decodeEntities: true
  5. }

For a full list of options and their effects, see this and htmlparser2’s options.

Selectors

Cheerio’s selector implementation is nearly identical to jQuery’s, so the API is very similar.

$( selector, [context], [root] )

selector searches within the context scope which searches within the root scope. selector and context can be an string expression, DOM Element, array of DOM elements, or cheerio object. root is typically the HTML document string.

This selector method is the starting point for traversing and manipulating the document. Like jQuery, it’s the primary method for selecting elements in the document, but unlike jQuery it’s built on top of the CSSSelect library, which implements most of the Sizzle selectors.

  1. $('.apple', '#fruits').text()
  2. //=> Apple
  3. $('ul .pear').attr('class')
  4. //=> pear
  5. $('li[class=orange]').html()
  6. //=> <li class="orange">Orange</li>

Attributes

Methods for getting and modifying attributes.

.attr( name, value )

Method for getting and setting attributes. Gets the attribute value for only the first element in the matched set. If you set an attribute’s value to null, you remove that attribute. You may also pass a map and function like jQuery.

  1. $('ul').attr('id')
  2. //=> fruits
  3. $('.apple').attr('id', 'favorite').html()
  4. //=> <li class="apple" id="favorite">Apple</li>

See http://api.jquery.com/attr/ for more information

.data( name, value )

Method for getting and setting data attributes. Gets or sets the data attribute value for only the first element in the matched set.

  1. $('<div data-apple-color="red"></div>').data()
  2. //=> { appleColor: 'red' }
  3. $('<div data-apple-color="red"></div>').data('data-apple-color')
  4. //=> 'red'
  5. var apple = $('.apple').data('kind', 'mac')
  6. apple.data('kind')
  7. //=> 'mac'

See http://api.jquery.com/data/ for more information

.val( [value] )

Method for getting and setting the value of input, select, and textarea. Note: Support for map, and function has not been added yet.

  1. $('input[type="text"]').val()
  2. //=> input_text
  3. $('input[type="text"]').val('test').html()
  4. //=> <input type="text" value="test"/>

.removeAttr( name )

Method for removing attributes by name.

  1. $('.pear').removeAttr('class').html()
  2. //=> <li>Pear</li>

.hasClass( className )

Check to see if any of the matched elements have the given className.

  1. $('.pear').hasClass('pear')
  2. //=> true
  3. $('apple').hasClass('fruit')
  4. //=> false
  5. $('li').hasClass('pear')
  6. //=> true

.addClass( className )

Adds class(es) to all of the matched elements. Also accepts a function like jQuery.

  1. $('.pear').addClass('fruit').html()
  2. //=> <li class="pear fruit">Pear</li>
  3. $('.apple').addClass('fruit red').html()
  4. //=> <li class="apple fruit red">Apple</li>

See http://api.jquery.com/addClass/ for more information.

.removeClass( [className] )

Removes one or more space-separated classes from the selected elements. If no className is defined, all classes will be removed. Also accepts a function like jQuery.

  1. $('.pear').removeClass('pear').html()
  2. //=> <li class="">Pear</li>
  3. $('.apple').addClass('red').removeClass().html()
  4. //=> <li class="">Apple</li>

See http://api.jquery.com/removeClass/ for more information.

.toggleClass( className, [switch] )

Add or remove class(es) from the matched elements, depending on either the class’s presence or the value of the switch argument. Also accepts a function like jQuery.

  1. $('.apple.green').toggleClass('fruit green red').html()
  2. //=> <li class="apple fruit red">Apple</li>
  3. $('.apple.green').toggleClass('fruit green red', true).html()
  4. //=> <li class="apple green fruit red">Apple</li>

See http://api.jquery.com/toggleClass/ for more information.

.is( selector )

.is( element )

.is( selection )

.is( function(index) )

Checks the current list of elements and returns true if any of the elements match the selector. If using an element or Cheerio selection, returns true if any of the elements match. If using a predicate function, the function is executed in the context of the selected element, so this refers to the current element.

Forms

.serializeArray()

Encode a set of form elements as an array of names and values.

  1. $('<form><input name="foo" value="bar" /></form>').serializeArray()
  2. //=> [ { name: 'foo', valule: 'bar' } ]

Traversing

.find(selector)

.find(selection)

.find(node)

Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

  1. $('#fruits').find('li').length
  2. //=> 3
  3. $('#fruits').find($('.apple')).length
  4. //=> 1

.parent([selector])

Get the parent of each element in the current set of matched elements, optionally filtered by a selector.

  1. $('.pear').parent().attr('id')
  2. //=> fruits

.parents([selector])

Get a set of parents filtered by selector of each element in the current set of match elements.

  1. $('.orange').parents().length
  2. // => 2
  3. $('.orange').parents('#fruits').length
  4. // => 1

.parentsUntil([selector][,filter])

Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or cheerio object.

  1. $('.orange').parentsUntil('#food').length
  2. // => 1

.closest(selector)

For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.

  1. $('.orange').closest()
  2. // => []
  3. $('.orange').closest('.apple')
  4. // => []
  5. $('.orange').closest('li')
  6. // => [<li class="orange">Orange</li>]
  7. $('.orange').closest('#fruits')
  8. // => [<ul id="fruits"> ... </ul>]

.next([selector])

Gets the next sibling of the first selected element, optionally filtered by a selector.

  1. $('.apple').next().hasClass('orange')
  2. //=> true

.nextAll([selector])

Gets all the following siblings of the first selected element, optionally filtered by a selector.

  1. $('.apple').nextAll()
  2. //=> [<li class="orange">Orange</li>, <li class="pear">Pear</li>]
  3. $('.apple').nextAll('.orange')
  4. //=> [<li class="orange">Orange</li>]

.nextUntil([selector], [filter])

Gets all the following siblings up to but not including the element matched by the selector, optionally filtered by another selector.

  1. $('.apple').nextUntil('.pear')
  2. //=> [<li class="orange">Orange</li>]

.prev([selector])

Gets the previous sibling of the first selected element optionally filtered by a selector.

  1. $('.orange').prev().hasClass('apple')
  2. //=> true

.prevAll([selector])

Gets all the preceding siblings of the first selected element, optionally filtered by a selector.

  1. $('.pear').prevAll()
  2. //=> [<li class="orange">Orange</li>, <li class="apple">Apple</li>]
  3. $('.pear').prevAll('.orange')
  4. //=> [<li class="orange">Orange</li>]

.prevUntil([selector], [filter])

Gets all the preceding siblings up to but not including the element matched by the selector, optionally filtered by another selector.

  1. $('.pear').prevUntil('.apple')
  2. //=> [<li class="orange">Orange</li>]

.slice( start, [end] )

Gets the elements matching the specified range

  1. $('li').slice(1).eq(0).text()
  2. //=> 'Orange'
  3. $('li').slice(1, 2).length
  4. //=> 1

.siblings( selector )

Gets the first selected element’s siblings, excluding itself.

  1. $('.pear').siblings().length
  2. //=> 2
  3. $('.pear').siblings('.orange').length
  4. //=> 1

.children( selector )

Gets the children of the first selected element.

  1. $('#fruits').children().length
  2. //=> 3
  3. $('#fruits').children('.pear').text()
  4. //=> Pear

.contents()

Gets the children of each element in the set of matched elements, including text and comment nodes.

  1. $('#fruits').contents().length
  2. //=> 3

.each( function(index, element) )

Iterates over a cheerio object, executing a function for each matched element. When the callback is fired, the function is fired in the context of the DOM element, so this refers to the current element, which is equivalent to the function parameter element. To break out of the each loop early, return with false.

  1. var fruits = [];
  2. $('li').each(function(i, elem) {
  3. fruits[i] = $(this).text();
  4. });
  5. fruits.join(', ');
  6. //=> Apple, Orange, Pear

.map( function(index, element) )

Pass each element in the current matched set through a function, producing a new Cheerio object containing the return values. The function can return an individual data item or an array of data items to be inserted into the resulting set. If an array is returned, the elements inside the array are inserted into the set. If the function returns null or undefined, no element will be inserted.

  1. $('li').map(function(i, el) {
  2. // this === el
  3. return $(this).text();
  4. }).get().join(' ');
  5. //=> "apple orange pear"

.filter( selector )
.filter( selection )
.filter( element )
.filter( function(index) )

Iterates over a cheerio object, reducing the set of selector elements to those that match the selector or pass the function’s test. When a Cheerio selection is specified, return only the elements contained in that selection. When an element is specified, return only that element (if it is contained in the original selection). If using the function method, the function is executed in the context of the selected element, so this refers to the current element.

Selector:

  1. $('li').filter('.orange').attr('class');
  2. //=> orange

Function:

  1. $('li').filter(function(i, el) {
  2. // this === el
  3. return $(this).attr('class') === 'orange';
  4. }).attr('class')
  5. //=> orange

.not( selector )
.not( selection )
.not( element )
.not( function(index, elem) )

Remove elements from the set of matched elements. Given a jQuery object that represents a set of DOM elements, the .not() method constructs a new jQuery object from a subset of the matching elements. The supplied selector is tested against each element; the elements that don’t match the selector will be included in the result. The .not() method can take a function as its argument in the same way that .filter() does. Elements for which the function returns true are excluded from the filtered set; all other elements are included.

Selector:

  1. $('li').not('.apple').length;
  2. //=> 2

Function:

  1. $('li').not(function(i, el) {
  2. // this === el
  3. return $(this).attr('class') === 'orange';
  4. }).length;
  5. //=> 2

.has( selector )
.has( element )

Filters the set of matched elements to only those which have the given DOM element as a descendant or which have a descendant that matches the given selector. Equivalent to .filter(':has(selector)').

Selector:

  1. $('ul').has('.pear').attr('id');
  2. //=> fruits

Element:

  1. $('ul').has($('.pear')[0]).attr('id');
  2. //=> fruits

.first()

Will select the first element of a cheerio object

  1. $('#fruits').children().first().text()
  2. //=> Apple

.last()

Will select the last element of a cheerio object

  1. $('#fruits').children().last().text()
  2. //=> Pear

.eq( i )

Reduce the set of matched elements to the one at the specified index. Use .eq(-i) to count backwards from the last selected element.

  1. $('li').eq(0).text()
  2. //=> Apple
  3. $('li').eq(-1).text()
  4. //=> Pear

.get( [i] )

Retrieve the DOM elements matched by the Cheerio object. If an index is specified, retrieve one of the elements matched by the Cheerio object:

  1. $('li').get(0).tagName
  2. //=> li

If no index is specified, retrieve all elements matched by the Cheerio object:

  1. $('li').get().length
  2. //=> 3

.index()

.index( selector )

.index( nodeOrSelection )

Search for a given element from among the matched elements.

  1. $('.pear').index()
  2. //=> 2
  3. $('.orange').index('li')
  4. //=> 1
  5. $('.apple').index($('#fruit, li'))
  6. //=> 1

.end()

End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.

  1. $('li').eq(0).end().length
  2. //=> 3

.add( selector [, context] )

.add( element )

.add( elements )

.add( html )

.add( selection )

Add elements to the set of matched elements.

  1. $('.apple').add('.orange').length
  2. //=> 2

.addBack( [filter] )

Add the previous set of elements on the stack to the current set, optionally filtered by a selector.

  1. $('li').eq(0).addBack('.orange').length
  2. //=> 2

Manipulation

Methods for modifying the DOM structure.

.append( content, [content, …] )

Inserts content as the last child of each of the selected elements.

  1. $('ul').append('<li class="plum">Plum</li>')
  2. $.html()
  3. //=> <ul id="fruits">
  4. // <li class="apple">Apple</li>
  5. // <li class="orange">Orange</li>
  6. // <li class="pear">Pear</li>
  7. // <li class="plum">Plum</li>
  8. // </ul>

.prepend( content, [content, …] )

Inserts content as the first child of each of the selected elements.

  1. $('ul').prepend('<li class="plum">Plum</li>')
  2. $.html()
  3. //=> <ul id="fruits">
  4. // <li class="plum">Plum</li>
  5. // <li class="apple">Apple</li>
  6. // <li class="orange">Orange</li>
  7. // <li class="pear">Pear</li>
  8. // </ul>

.after( content, [content, …] )

Insert content next to each element in the set of matched elements.

  1. $('.apple').after('<li class="plum">Plum</li>')
  2. $.html()
  3. //=> <ul id="fruits">
  4. // <li class="apple">Apple</li>
  5. // <li class="plum">Plum</li>
  6. // <li class="orange">Orange</li>
  7. // <li class="pear">Pear</li>
  8. // </ul>

.insertAfter( content )

Insert every element in the set of matched elements after the target.

  1. $('<li class="plum">Plum</li>').insertAfter('.apple')
  2. $.html()
  3. //=> <ul id="fruits">
  4. // <li class="apple">Apple</li>
  5. // <li class="plum">Plum</li>
  6. // <li class="orange">Orange</li>
  7. // <li class="pear">Pear</li>
  8. // </ul>

.before( content, [content, …] )

Insert content previous to each element in the set of matched elements.

  1. $('.apple').before('<li class="plum">Plum</li>')
  2. $.html()
  3. //=> <ul id="fruits">
  4. // <li class="plum">Plum</li>
  5. // <li class="apple">Apple</li>
  6. // <li class="orange">Orange</li>
  7. // <li class="pear">Pear</li>
  8. // </ul>

.insertBefore( content )

Insert every element in the set of matched elements before the target.

  1. $('<li class="plum">Plum</li>').insertBefore('.apple')
  2. $.html()
  3. //=> <ul id="fruits">
  4. // <li class="plum">Plum</li>
  5. // <li class="apple">Apple</li>
  6. // <li class="orange">Orange</li>
  7. // <li class="pear">Pear</li>
  8. // </ul>

.remove( [selector] )

Removes the set of matched elements from the DOM and all their children. selector filters the set of matched elements to be removed.

  1. $('.pear').remove()
  2. $.html()
  3. //=> <ul id="fruits">
  4. // <li class="apple">Apple</li>
  5. // <li class="orange">Orange</li>
  6. // </ul>

.replaceWith( content )

Replaces matched elements with content.

  1. var plum = $('<li class="plum">Plum</li>')
  2. $('.pear').replaceWith(plum)
  3. $.html()
  4. //=> <ul id="fruits">
  5. // <li class="apple">Apple</li>
  6. // <li class="orange">Orange</li>
  7. // <li class="plum">Plum</li>
  8. // </ul>

.empty()

Empties an element, removing all its children.

  1. $('ul').empty()
  2. $.html()
  3. //=> <ul id="fruits"></ul>

.html( [htmlString] )

Gets an html content string from the first selected element. If htmlString is specified, each selected element’s content is replaced by the new content.

  1. $('.orange').html()
  2. //=> Orange
  3. $('#fruits').html('<li class="mango">Mango</li>').html()
  4. //=> <li class="mango">Mango</li>

.text( [textString] )

Get the combined text contents of each element in the set of matched elements, including their descendants.. If textString is specified, each selected element’s content is replaced by the new text content.

  1. $('.orange').text()
  2. //=> Orange
  3. $('ul').text()
  4. //=> Apple
  5. // Orange
  6. // Pear

.css( [propertName] )
.css( [ propertyNames] )
.css( [propertyName], [value] )
.css( [propertName], [function] )
.css( [properties] )

Get the value of a style property for the first element in the set of matched elements or set one or more CSS properties for every matched element.

Rendering

When you’re ready to render the document, you can use the html utility function:

  1. $.html()
  2. //=> <ul id="fruits">
  3. // <li class="apple">Apple</li>
  4. // <li class="orange">Orange</li>
  5. // <li class="pear">Pear</li>
  6. // </ul>

If you want to return the outerHTML you can use $.html(selector):

  1. $.html('.pear')
  2. //=> <li class="pear">Pear</li>

By default, html will leave some tags open. Sometimes you may instead want to render a valid XML document. For example, you might parse the following XML snippet:

  1. $ = cheerio.load('<media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123"/>');

… and later want to render to XML. To do this, you can use the ‘xml’ utility function:

  1. $.xml()
  2. //=> <media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123"/>

Miscellaneous

DOM element methods that don’t fit anywhere else

.clone()

Clone the cheerio object.

  1. var moreFruit = $('#fruits').clone()

Utilities

$.root

Sometimes you need to work with the top-level root element. To query it, you can use $.root().

  1. $.root().append('<ul id="vegetables"></ul>').html();
  2. //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>

$.contains( container, contained )

Checks to see if the contained DOM element is a descendent of the container DOM element.

$.parseHTML( data [, context ] [, keepScripts ] )

Parses a string into an array of DOM nodes. The context argument has no meaning for Cheerio, but it is maintained for API compatability.

Plugins

Once you have loaded a document, you may extend the prototype or the equivalent fn property with custom plugin methods:

  1. var $ = cheerio.load('<html><body>Hello, <b>world</b>!</body></html>');
  2. $.prototype.logHtml = function() {
  3. console.log(this.html());
  4. };
  5. $('body').logHtml(); // logs "Hello, <b>world</b>!" to the console

The “DOM Node” object

Cheerio collections are made up of objects that bear some resemblence to browser-based DOM nodes. You can expect them to define the following properties:

  • tagName
  • parentNode
  • previousSibling
  • nextSibling
  • nodeValue
  • firstChild
  • childNodes
  • lastChild

Screencasts

http://vimeo.com/31950192

This video tutorial is a follow-up to Nettut’s “How to Scrape Web Pages with Node.js and jQuery”, using cheerio instead of JSDOM + jQuery. This video shows how easy it is to use cheerio and how much faster cheerio is than JSDOM + jQuery.

Test Coverage

Cheerio has high-test coverage, you can view the report here.

Testing

To run the test suite, download the repository, then within the cheerio directory, run:

  1. make setup
  2. make test

This will download the development packages and run the test suite.

Contributors

These are some of the contributors that have made cheerio possible:

  1. project : cheerio
  2. repo age : 2 years, 6 months
  3. active : 285 days
  4. commits : 762
  5. files : 36
  6. authors :
  7. 293 Matt Mueller 38.5%
  8. 133 Matthew Mueller 17.5%
  9. 92 Mike Pennisi 12.1%
  10. 54 David Chambers 7.1%
  11. 30 kpdecker 3.9%
  12. 19 Felix Böhm 2.5%
  13. 17 fb55 2.2%
  14. 15 Siddharth Mahendraker 2.0%
  15. 11 Adam Bretz 1.4%
  16. 8 Nazar Leush 1.0%
  17. 7 ironchefpython 0.9%
  18. 6 Jarno Leppänen 0.8%
  19. 5 Ben Sheldon 0.7%
  20. 5 Jos Shepherd 0.7%
  21. 5 Ryan Schmukler 0.7%
  22. 5 Steven Vachon 0.7%
  23. 4 Maciej Adwent 0.5%
  24. 4 Amir Abu Shareb 0.5%
  25. 3 jeremy.dentel@brandingbrand.com 0.4%
  26. 3 Andi Neck 0.4%
  27. 2 steve 0.3%
  28. 2 alexbardas 0.3%
  29. 2 finspin 0.3%
  30. 2 Ali Farhadi 0.3%
  31. 2 Chris Khoo 0.3%
  32. 2 Rob Ashton 0.3%
  33. 2 Thomas Heymann 0.3%
  34. 2 Jaro Spisak 0.3%
  35. 2 Dan Dascalescu 0.3%
  36. 2 Torstein Thune 0.3%
  37. 2 Wayne Larsen 0.3%
  38. 1 Timm Preetz 0.1%
  39. 1 Xavi 0.1%
  40. 1 Alex Shaindlin 0.1%
  41. 1 mattym 0.1%
  42. 1 Felix Böhm 0.1%
  43. 1 Farid Neshat 0.1%
  44. 1 Dmitry Mazuro 0.1%
  45. 1 Jeremy Hubble 0.1%
  46. 1 nevermind 0.1%
  47. 1 Manuel Alabor 0.1%
  48. 1 Matt Liegey 0.1%
  49. 1 Chris O'Hara 0.1%
  50. 1 Michael Holroyd 0.1%
  51. 1 Michiel De Mey 0.1%
  52. 1 Ben Atkin 0.1%
  53. 1 Rich Trott 0.1%
  54. 1 Rob "Hurricane" Ashton 0.1%
  55. 1 Robin Gloster 0.1%
  56. 1 Simon Boudrias 0.1%
  57. 1 Sindre Sorhus 0.1%
  58. 1 xiaohwan 0.1%

Cheerio in the real world

Are you using cheerio in production? Add it to the wiki!

Special Thanks

This library stands on the shoulders of some incredible developers. A special thanks to:

• @FB55 for node-htmlparser2 & CSSSelect: Felix has a knack for writing speedy parsing engines. He completely re-wrote both @tautologistic’s node-htmlparser and @harry’s node-soupselect from the ground up, making both of them much faster and more flexible. Cheerio would not be possible without his foundational work

• @jQuery team for jQuery: The core API is the best of its class and despite dealing with all the browser inconsistencies the code base is extremely clean and easy to follow. Much of cheerio’s implementation and documentation is from jQuery. Thanks guys.

• @visionmedia: The style, the structure, the open-source”-ness” of this library comes from studying TJ’s style and using many of his libraries. This dude consistently pumps out high-quality libraries and has always been more than willing to help or answer questions. You rock TJ.

License

(The MIT License)

Copyright (c) 2012 Matt Mueller <mattmuelle@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.