-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
remove node module caching dependency #1691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| 'use strict'; | ||
| /** | ||
| * @module cheerio/load | ||
| * @ignore | ||
| */ | ||
| var defaultOptions = require('./options').default; | ||
| var flattenOptions = require('./options').flatten; | ||
| var staticMethods = require('./static'); | ||
| var Cheerio = require('./cheerio'); | ||
| var parse = require('./parse'); | ||
|
|
||
| /** | ||
| * Create a querying function, bound to a document created from the provided | ||
| * markup. Note that similar to web browser contexts, this operation may | ||
| * introduce `<html>`, `<head>`, and `<body>` elements; set `isDocument` to | ||
| * `false` to switch to fragment mode and disable this. | ||
| * | ||
| * See the README section titled "Loading" for additional usage information. | ||
| * | ||
| * @param {string} content - Markup to be loaded. | ||
| * @param {object} [options] - Options for the created instance. | ||
| * @param {boolean} [isDocument] - Allows parser to be switched to fragment mode. | ||
| * @returns {Cheerio} - The loaded document. | ||
| */ | ||
| exports.load = function (content, options, isDocument) { | ||
| if (content === null || content === undefined) { | ||
| throw new Error('cheerio.load() expects a string'); | ||
| } | ||
|
|
||
| options = Object.assign({}, defaultOptions, flattenOptions(options)); | ||
|
|
||
| if (typeof isDocument === 'undefined') isDocument = true; | ||
|
|
||
| var root = parse(content, options, isDocument); | ||
|
|
||
| function initialize(selector, context, r, opts) { | ||
| if (!(this instanceof initialize)) { | ||
| return new initialize(selector, context, r, opts); | ||
| } | ||
| opts = Object.assign({}, options, opts); | ||
| return Cheerio.call(this, selector, context, r || root, opts); | ||
| } | ||
|
|
||
| // Ensure that selections created by the "loaded" `initialize` function are | ||
| // true Cheerio instances. | ||
| initialize.prototype = Object.create(Cheerio.prototype); | ||
| initialize.prototype.constructor = initialize; | ||
|
|
||
| // Mimic jQuery's prototype alias for plugin authors. | ||
| initialize.fn = initialize.prototype; | ||
|
|
||
| // Keep a reference to the top-level scope so we can chain methods that implicitly | ||
| // resolve selectors; e.g. $("<span>").(".bar"), which otherwise loses ._root | ||
| initialize.prototype._originalRoot = root; | ||
|
|
||
| // Add in the static methods | ||
| Object.assign(initialize, staticMethods, exports); | ||
|
|
||
| // Add in the root | ||
| initialize._root = root; | ||
| // store options | ||
| initialize._options = options; | ||
|
|
||
| return initialize; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.