changed action for arc cluster to use az connectedk8s proxy
This commit is contained in:
parent
e5a2133107
commit
23202c929e
44
.github/workflows/main.yml
vendored
Normal file
44
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: k8s-set-context
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the master branch
|
||||
push:
|
||||
branches: [ cluster-connect-2 ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Runs a single command using the runners shell
|
||||
- name: Run a one-line script
|
||||
run: echo Hello, world!
|
||||
|
||||
# Runs a set of commands using the runners shell
|
||||
- name: Run a multi-line script
|
||||
run: |
|
||||
echo Add other actions to build,
|
||||
echo test, and deploy your project.
|
||||
- uses: atharvamulmuley/k8s-set-context@cluster-connect-2
|
||||
with:
|
||||
method: service-account
|
||||
cluster-type: 'arc'
|
||||
creds: '${{ secrets.AZURE_CREDS }}'
|
||||
cluster-name: arcaction
|
||||
resource-group: atharvatest2
|
||||
token: '${{ secrets.SA_TOKEN }}'
|
||||
- run: |
|
||||
kubectl get pods -A
|
52
README.md
52
README.md
@ -6,6 +6,7 @@ There are two approaches for specifying the deployment target:
|
||||
|
||||
- Kubeconfig file provided as input to the action
|
||||
- Service account approach where the secret associated with the service account is provided as input to the action
|
||||
- Service principal approach(only applicable for arc cluster) where service principal provided with 'creds' is used as input to action
|
||||
|
||||
If inputs related to both these approaches are provided, kubeconfig approach related inputs are given precedence.
|
||||
|
||||
@ -22,7 +23,7 @@ In both these approaches it is recommended to store these contents (kubeconfig f
|
||||
</thead>
|
||||
<tr>
|
||||
<td><code>method</code><br/>Method</td>
|
||||
<td>(Optional) Acceptable values: kubeconfig/service-account. Default value: kubeconfig</td>
|
||||
<td>(Optional) Acceptable values: kubeconfig/service-account/spn. Default value: kubeconfig</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>kubeconfig</code><br/>Kubectl config</td>
|
||||
@ -40,6 +41,26 @@ In both these approaches it is recommended to store these contents (kubeconfig f
|
||||
<td><code>k8s-secret</code><br/>Secret</td>
|
||||
<td>(Relevant for service account approach) Secret associated with the service account to be used for deployments</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>cluster-type</code><br/>Type of cluster</td>
|
||||
<td>Type of cluster. Acceptable values: generic/arc</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>creds</code><br/>Service principal credentials for az login</td>
|
||||
<td>Provide json output of 'az ad sp create-for-rbac --sdk-auth' command</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>cluster-name</code><br/>Name of arc cluster</td>
|
||||
<td>Provide name of arc cluster.Applicable for cluster-type of 'arc'.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>resource-group</code><br/>resource group</td>
|
||||
<td>Provide name of resource group that contains the arc cluster.Applicable for cluster-type of 'arc'.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>token</code><br/>Service account token</td>
|
||||
<td>Applicable for 'service-account' method.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Example usage
|
||||
@ -101,6 +122,33 @@ kubectl get serviceAccounts <service-account-name> -n <namespace> -o 'jsonpath={
|
||||
kubectl get secret <service-account-secret-name> -n <namespace> -o yaml
|
||||
```
|
||||
|
||||
### Service account approach for arc cluster
|
||||
|
||||
```yaml
|
||||
- uses: azure/k8s-set-context@v1
|
||||
with:
|
||||
method: service-account
|
||||
cluster-type: 'arc'
|
||||
creds: '${{ secrets.AZURE_CREDS }}'
|
||||
cluster-name: <cluster-name>
|
||||
resource-group: <resource-group>
|
||||
token: '${{ secrets.SA_TOKEN }}'
|
||||
id: setcontext
|
||||
```
|
||||
|
||||
### Service principal approach for arc cluster
|
||||
|
||||
```yaml
|
||||
- uses: azure/k8s-set-context@v1
|
||||
with:
|
||||
method: spn
|
||||
cluster-type: 'arc'
|
||||
creds: '${{ secrets.AZURE_CREDS }}'
|
||||
cluster-name: <cluster-name>
|
||||
resource-group: <resource-group>
|
||||
id: setcontext
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
@ -113,4 +161,4 @@ provided by the bot. You will only need to do this once across all repos using o
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
18
action.yml
18
action.yml
@ -7,7 +7,7 @@ inputs:
|
||||
required: true
|
||||
default: 'generic'
|
||||
method:
|
||||
description: 'Acceptable values: kubeconfig or service-account'
|
||||
description: 'Acceptable values: kubeconfig or service-account or spn'
|
||||
required: true
|
||||
default: 'kubeconfig'
|
||||
kubeconfig:
|
||||
@ -44,8 +44,22 @@ inputs:
|
||||
description: 'Azure connected cluster name'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
# inputs for az login
|
||||
enable-AzPSSession:
|
||||
description: 'Set this value to true to enable Azure PowerShell Login in addition to Az CLI login'
|
||||
required: false
|
||||
default: false
|
||||
environment:
|
||||
description: 'Name of the environment. Supported values are azurecloud, azurestack, azureusgovernment, azurechinacloud, azuregermancloud. Default being azurecloud'
|
||||
required: false
|
||||
default: AzureCloud
|
||||
allow-no-subscriptions:
|
||||
description: 'Set this value to true to enable support for accessing tenants without subscriptions'
|
||||
required: false
|
||||
default: false
|
||||
branding:
|
||||
color: 'green' # optional, decorates the entry in the GitHub Marketplace
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/login.js'
|
||||
main: 'lib/login.js'
|
14
lib/PowerShell/Constants.js
Normal file
14
lib/PowerShell/Constants.js
Normal file
@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class Constants {
|
||||
}
|
||||
exports.default = Constants;
|
||||
Constants.prefix = "az_";
|
||||
Constants.moduleName = "Az.Accounts";
|
||||
Constants.versionPattern = /[0-9]\.[0-9]\.[0-9]/;
|
||||
Constants.AzureCloud = "AzureCloud";
|
||||
Constants.Subscription = "Subscription";
|
||||
Constants.ServicePrincipal = "ServicePrincipal";
|
||||
Constants.Success = "Success";
|
||||
Constants.Error = "Error";
|
||||
Constants.AzVersion = "AzVersion";
|
0
lib/PowerShell/IAzurePowerShellSession.js
Normal file
0
lib/PowerShell/IAzurePowerShellSession.js
Normal file
67
lib/PowerShell/ServicePrincipalLogin.js
Normal file
67
lib/PowerShell/ServicePrincipalLogin.js
Normal file
@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = require("@actions/core");
|
||||
const Utils_1 = require("./Utilities/Utils");
|
||||
const PowerShellToolRunner_1 = require("./Utilities/PowerShellToolRunner");
|
||||
const ScriptBuilder_1 = require("./Utilities/ScriptBuilder");
|
||||
const Constants_1 = require("./Constants");
|
||||
class ServicePrincipalLogin {
|
||||
constructor(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin, environment, resourceManagerEndpointUrl) {
|
||||
this.servicePrincipalId = servicePrincipalId;
|
||||
this.servicePrincipalKey = servicePrincipalKey;
|
||||
this.tenantId = tenantId;
|
||||
this.subscriptionId = subscriptionId;
|
||||
this.environment = environment;
|
||||
this.resourceManagerEndpointUrl = resourceManagerEndpointUrl;
|
||||
this.allowNoSubscriptionsLogin = allowNoSubscriptionsLogin;
|
||||
}
|
||||
initialize() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
Utils_1.default.setPSModulePath();
|
||||
const azLatestVersion = yield Utils_1.default.getLatestModule(Constants_1.default.moduleName);
|
||||
core.debug(`Az Module version used: ${azLatestVersion}`);
|
||||
Utils_1.default.setPSModulePath(`${Constants_1.default.prefix}${azLatestVersion}`);
|
||||
});
|
||||
}
|
||||
login() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let output = "";
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
output += data.toString();
|
||||
}
|
||||
}
|
||||
};
|
||||
const args = {
|
||||
servicePrincipalId: this.servicePrincipalId,
|
||||
servicePrincipalKey: this.servicePrincipalKey,
|
||||
subscriptionId: this.subscriptionId,
|
||||
environment: this.environment,
|
||||
scopeLevel: ServicePrincipalLogin.scopeLevel,
|
||||
allowNoSubscriptionsLogin: this.allowNoSubscriptionsLogin,
|
||||
resourceManagerEndpointUrl: this.resourceManagerEndpointUrl
|
||||
};
|
||||
const script = new ScriptBuilder_1.default().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
|
||||
yield PowerShellToolRunner_1.default.init();
|
||||
yield PowerShellToolRunner_1.default.executePowerShellScriptBlock(script, options);
|
||||
const result = JSON.parse(output.trim());
|
||||
if (!(Constants_1.default.Success in result)) {
|
||||
throw new Error(`Azure PowerShell login failed with error: ${result[Constants_1.default.Error]}`);
|
||||
}
|
||||
console.log(`Azure PowerShell session successfully initialized`);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ServicePrincipalLogin = ServicePrincipalLogin;
|
||||
ServicePrincipalLogin.scopeLevel = Constants_1.default.Subscription;
|
||||
ServicePrincipalLogin.scheme = Constants_1.default.ServicePrincipal;
|
28
lib/PowerShell/Utilities/PowerShellToolRunner.js
Normal file
28
lib/PowerShell/Utilities/PowerShellToolRunner.js
Normal file
@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const io = require("@actions/io");
|
||||
const exec = require("@actions/exec");
|
||||
class PowerShellToolRunner {
|
||||
static init() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!PowerShellToolRunner.psPath) {
|
||||
PowerShellToolRunner.psPath = yield io.which("pwsh", true);
|
||||
}
|
||||
});
|
||||
}
|
||||
static executePowerShellScriptBlock(scriptBlock, options = {}) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield exec.exec(`"${PowerShellToolRunner.psPath}" -Command`, [scriptBlock], options);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = PowerShellToolRunner;
|
55
lib/PowerShell/Utilities/ScriptBuilder.js
Normal file
55
lib/PowerShell/Utilities/ScriptBuilder.js
Normal file
@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = require("@actions/core");
|
||||
const Constants_1 = require("../Constants");
|
||||
class ScriptBuilder {
|
||||
constructor() {
|
||||
this.script = "";
|
||||
}
|
||||
getAzPSLoginScript(scheme, tenantId, args) {
|
||||
let command = `Clear-AzContext -Scope Process;
|
||||
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue;`;
|
||||
if (scheme === Constants_1.default.ServicePrincipal) {
|
||||
if (args.environment.toLowerCase() == "azurestack") {
|
||||
command += `Add-AzEnvironment -Name ${args.environment} -ARMEndpoint ${args.resourceManagerEndpointUrl} | out-null;`;
|
||||
}
|
||||
command += `Connect-AzAccount -ServicePrincipal -Tenant '${tenantId}' -Credential \
|
||||
(New-Object System.Management.Automation.PSCredential('${args.servicePrincipalId}',(ConvertTo-SecureString '${args.servicePrincipalKey.replace("'", "''")}' -AsPlainText -Force))) \
|
||||
-Environment '${args.environment}' | out-null;`;
|
||||
if (args.scopeLevel === Constants_1.default.Subscription && !args.allowNoSubscriptionsLogin) {
|
||||
command += `Set-AzContext -SubscriptionId '${args.subscriptionId}' -TenantId '${tenantId}' | out-null;`;
|
||||
}
|
||||
}
|
||||
this.script += `try {
|
||||
$ErrorActionPreference = "Stop"
|
||||
$WarningPreference = "SilentlyContinue"
|
||||
$output = @{}
|
||||
${command}
|
||||
$output['${Constants_1.default.Success}'] = "true"
|
||||
}
|
||||
catch {
|
||||
$output['${Constants_1.default.Error}'] = $_.exception.Message
|
||||
}
|
||||
return ConvertTo-Json $output`;
|
||||
core.debug(`Azure PowerShell Login Script: ${this.script}`);
|
||||
return this.script;
|
||||
}
|
||||
getLatestModuleScript(moduleName) {
|
||||
const command = `Get-Module -Name ${moduleName} -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1`;
|
||||
this.script += `try {
|
||||
$ErrorActionPreference = "Stop"
|
||||
$WarningPreference = "SilentlyContinue"
|
||||
$output = @{}
|
||||
$data = ${command}
|
||||
$output['${Constants_1.default.AzVersion}'] = $data.Version.ToString()
|
||||
$output['${Constants_1.default.Success}'] = "true"
|
||||
}
|
||||
catch {
|
||||
$output['${Constants_1.default.Error}'] = $_.exception.Message
|
||||
}
|
||||
return ConvertTo-Json $output`;
|
||||
core.debug(`GetLatestModuleScript: ${this.script}`);
|
||||
return this.script;
|
||||
}
|
||||
}
|
||||
exports.default = ScriptBuilder;
|
70
lib/PowerShell/Utilities/Utils.js
Normal file
70
lib/PowerShell/Utilities/Utils.js
Normal file
@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = require("os");
|
||||
const Constants_1 = require("../Constants");
|
||||
const ScriptBuilder_1 = require("./ScriptBuilder");
|
||||
const PowerShellToolRunner_1 = require("./PowerShellToolRunner");
|
||||
class Utils {
|
||||
/**
|
||||
* Add the folder path where Az modules are present to PSModulePath based on runner
|
||||
* @param azPSVersion
|
||||
* If azPSVersion is empty, folder path in which all Az modules are present are set
|
||||
* If azPSVersion is not empty, folder path of exact Az module version is set
|
||||
*/
|
||||
static setPSModulePath(azPSVersion = "") {
|
||||
let modulePath = "";
|
||||
const runner = process.env.RUNNER_OS || os.type();
|
||||
switch (runner.toLowerCase()) {
|
||||
case "linux":
|
||||
modulePath = `/usr/share/${azPSVersion}:`;
|
||||
break;
|
||||
case "windows":
|
||||
case "windows_nt":
|
||||
modulePath = `C:\\Modules\\${azPSVersion};`;
|
||||
break;
|
||||
case "macos":
|
||||
case "darwin":
|
||||
throw new Error(`OS not supported`);
|
||||
default:
|
||||
throw new Error(`Unknown os: ${runner.toLowerCase()}`);
|
||||
}
|
||||
process.env.PSModulePath = `${modulePath}${process.env.PSModulePath}`;
|
||||
}
|
||||
static getLatestModule(moduleName) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let output = "";
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
output += data.toString();
|
||||
}
|
||||
}
|
||||
};
|
||||
yield PowerShellToolRunner_1.default.init();
|
||||
yield PowerShellToolRunner_1.default.executePowerShellScriptBlock(new ScriptBuilder_1.default()
|
||||
.getLatestModuleScript(moduleName), options);
|
||||
const result = JSON.parse(output.trim());
|
||||
if (!(Constants_1.default.Success in result)) {
|
||||
throw new Error(result[Constants_1.default.Error]);
|
||||
}
|
||||
const azLatestVersion = result[Constants_1.default.AzVersion];
|
||||
if (!Utils.isValidVersion(azLatestVersion)) {
|
||||
throw new Error(`Invalid AzPSVersion: ${azLatestVersion}`);
|
||||
}
|
||||
return azLatestVersion;
|
||||
});
|
||||
}
|
||||
static isValidVersion(version) {
|
||||
return !!version.match(Constants_1.default.versionPattern);
|
||||
}
|
||||
}
|
||||
exports.default = Utils;
|
@ -12,6 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = require("@actions/core");
|
||||
const client_1 = require("./client");
|
||||
const querystring = require("querystring");
|
||||
const az_login = require("./main");
|
||||
const path = require("path");
|
||||
const child_process_1 = require("child_process");
|
||||
const fs = require("fs");
|
||||
function getAzureAccessToken(servicePrincipalId, servicePrincipalKey, tenantId, authorityUrl, managementEndpointUrl) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !authorityUrl) {
|
||||
@ -52,51 +56,47 @@ function getAzureAccessToken(servicePrincipalId, servicePrincipalKey, tenantId,
|
||||
function getArcKubeconfig() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
let creds = core.getInput('creds');
|
||||
let credsObject;
|
||||
try {
|
||||
credsObject = JSON.parse(creds);
|
||||
let method = core.getInput('method');
|
||||
if (method != 'service-account' && method != 'spn') {
|
||||
throw Error("Supported methods for arc cluster are 'service-account' and 'spn'.");
|
||||
}
|
||||
catch (ex) {
|
||||
throw new Error('Credentials object is not a valid JSON: ' + ex);
|
||||
}
|
||||
let servicePrincipalId = credsObject["clientId"];
|
||||
let servicePrincipalKey = credsObject["clientSecret"];
|
||||
let tenantId = credsObject["tenantId"];
|
||||
let authorityUrl = credsObject["activeDirectoryEndpointUrl"] || "https://login.microsoftonline.com";
|
||||
let managementEndpointUrl = credsObject["resourceManagerEndpointUrl"] || "https://management.azure.com/";
|
||||
let subscriptionId = credsObject["subscriptionId"];
|
||||
let azureSessionToken = yield getAzureAccessToken(servicePrincipalId, servicePrincipalKey, tenantId, authorityUrl, managementEndpointUrl).catch(ex => {
|
||||
throw new Error('Could not fetch the azure access token: ' + ex);
|
||||
});
|
||||
let resourceGroupName = core.getInput('resource-group');
|
||||
let clusterName = core.getInput('cluster-name');
|
||||
let saToken = core.getInput('token');
|
||||
return new Promise((resolve, reject) => {
|
||||
var webRequest = new client_1.WebRequest();
|
||||
webRequest.method = 'POST';
|
||||
webRequest.uri = `${managementEndpointUrl}/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/${clusterName}/listClusterUserCredentials?api-version=2020-01-01-preview`;
|
||||
webRequest.headers = {
|
||||
'Authorization': 'Bearer ' + azureSessionToken,
|
||||
'Content-Type': 'application/json; charset=utf-8'
|
||||
};
|
||||
webRequest.body = JSON.stringify({
|
||||
authenticationMethod: "Token",
|
||||
value: {
|
||||
token: saToken
|
||||
}
|
||||
});
|
||||
client_1.sendRequest(webRequest).then((response) => {
|
||||
let kubeconfigs = response.body.kubeconfigs;
|
||||
if (kubeconfigs && kubeconfigs.length > 0) {
|
||||
var kubeconfig = Buffer.from(kubeconfigs[0].value, 'base64');
|
||||
resolve(kubeconfig.toString());
|
||||
}
|
||||
else {
|
||||
reject(JSON.stringify(response.body));
|
||||
}
|
||||
}).catch(reject);
|
||||
});
|
||||
if (!resourceGroupName) {
|
||||
throw Error("'resourceGroupName' is not passed for arc cluster.");
|
||||
}
|
||||
if (!clusterName) {
|
||||
throw Error("'clusterName' is not passed for arc cluster.");
|
||||
}
|
||||
yield az_login.main();
|
||||
yield az_login.executeAzCliCommand(`account show`, false);
|
||||
yield az_login.executeAzCliCommand(`extension add -n connectedk8s`, false);
|
||||
yield az_login.executeAzCliCommand(`extension list`, false);
|
||||
const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated
|
||||
const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`);
|
||||
if (method == 'service-account') {
|
||||
let saToken = core.getInput('token');
|
||||
if (!saToken) {
|
||||
throw Error("'saToken' is not passed for 'service-account' method.");
|
||||
}
|
||||
console.log('using service account method for authenticating to arc cluster.');
|
||||
child_process_1.spawn('az', ['connectedk8s', 'proxy', '-n', clusterName, '-g', resourceGroupName, '-f', kubeconfigPath, '--token', saToken], {
|
||||
detached: true,
|
||||
stdio: 'ignore'
|
||||
}).unref();
|
||||
}
|
||||
else {
|
||||
console.log('using spn method for authenticating to arc cluster.');
|
||||
child_process_1.spawn('az', ['connectedk8s', 'proxy', '-n', clusterName, '-g', resourceGroupName, '-f', kubeconfigPath], {
|
||||
detached: true,
|
||||
stdio: 'ignore'
|
||||
}).unref();
|
||||
}
|
||||
console.log('started proxy');
|
||||
yield sleep(120000); //sleeping for a minute to allow kubeconfig to be merged
|
||||
fs.chmodSync(kubeconfigPath, '600');
|
||||
core.exportVariable('KUBECONFIG', kubeconfigPath);
|
||||
console.log('KUBECONFIG environment variable is set');
|
||||
}
|
||||
catch (ex) {
|
||||
return Promise.reject(ex);
|
||||
@ -104,3 +104,6 @@ function getArcKubeconfig() {
|
||||
});
|
||||
}
|
||||
exports.getArcKubeconfig = getArcKubeconfig;
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
18
lib/login.js
18
lib/login.js
@ -111,21 +111,21 @@ function run() {
|
||||
let kubeconfig = '';
|
||||
const cluster_type = core.getInput('cluster-type', { required: true });
|
||||
if (cluster_type == 'arc') {
|
||||
kubeconfig = yield arc_login_1.getArcKubeconfig().catch(ex => {
|
||||
yield arc_login_1.getArcKubeconfig().catch(ex => {
|
||||
throw new Error('Error: Could not get the KUBECONFIG for arc cluster: ' + ex);
|
||||
});
|
||||
}
|
||||
else {
|
||||
const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated
|
||||
const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`);
|
||||
kubeconfig = getKubeconfig();
|
||||
core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`);
|
||||
fs.writeFileSync(kubeconfigPath, kubeconfig);
|
||||
fs.chmodSync(kubeconfigPath, '600');
|
||||
core.exportVariable('KUBECONFIG', kubeconfigPath);
|
||||
console.log('KUBECONFIG environment variable is set');
|
||||
yield setContext(kubeconfigPath);
|
||||
}
|
||||
const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated
|
||||
const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`);
|
||||
core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`);
|
||||
fs.writeFileSync(kubeconfigPath, kubeconfig);
|
||||
fs.chmodSync(kubeconfigPath, '600');
|
||||
core.exportVariable('KUBECONFIG', kubeconfigPath);
|
||||
console.log('KUBECONFIG environment variable is set');
|
||||
yield setContext(kubeconfigPath);
|
||||
}
|
||||
catch (ex) {
|
||||
return Promise.reject(ex);
|
||||
|
163
lib/main.js
Normal file
163
lib/main.js
Normal file
@ -0,0 +1,163 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = require("@actions/core");
|
||||
const exec = require("@actions/exec");
|
||||
const io = require("@actions/io");
|
||||
const actions_secret_parser_1 = require("actions-secret-parser");
|
||||
const ServicePrincipalLogin_1 = require("./PowerShell/ServicePrincipalLogin");
|
||||
var azPath;
|
||||
var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : "";
|
||||
var azPSHostEnv = !!process.env.AZUREPS_HOST_ENVIRONMENT ? `${process.env.AZUREPS_HOST_ENVIRONMENT}` : "";
|
||||
function main() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
// Set user agent variable
|
||||
var isAzCLISuccess = false;
|
||||
let usrAgentRepo = `${process.env.GITHUB_REPOSITORY}`;
|
||||
let actionName = 'AzureLogin';
|
||||
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||
let azurePSHostEnv = (!!azPSHostEnv ? `${azPSHostEnv}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
|
||||
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
|
||||
azPath = yield io.which("az", true);
|
||||
let azureSupportedCloudName = new Set([
|
||||
"azureusgovernment",
|
||||
"azurechinacloud",
|
||||
"azuregermancloud",
|
||||
"azurecloud",
|
||||
"azurestack"
|
||||
]);
|
||||
let output = "";
|
||||
const execOptions = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
output += data.toString();
|
||||
}
|
||||
}
|
||||
};
|
||||
yield executeAzCliCommand("--version", true, execOptions);
|
||||
core.debug(`az cli version used:\n${output}`);
|
||||
let creds = core.getInput('creds', { required: true });
|
||||
let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON);
|
||||
let servicePrincipalId = secrets.getSecret("$.clientId", false);
|
||||
let servicePrincipalKey = secrets.getSecret("$.clientSecret", true);
|
||||
let tenantId = secrets.getSecret("$.tenantId", false);
|
||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||
let resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
||||
let environment = core.getInput("environment").toLowerCase();
|
||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||
}
|
||||
if (!subscriptionId && !allowNoSubscriptionsLogin) {
|
||||
throw new Error("Not all values are present in the creds object. Ensure subscriptionId is supplied.");
|
||||
}
|
||||
if (!azureSupportedCloudName.has(environment)) {
|
||||
throw new Error("Unsupported value for environment is passed.The list of supported values for environment are ‘azureusgovernment', ‘azurechinacloud’, ‘azuregermancloud’, ‘azurecloud’ or ’azurestack’");
|
||||
}
|
||||
// Attempting Az cli login
|
||||
if (environment == "azurestack") {
|
||||
if (!resourceManagerEndpointUrl) {
|
||||
throw new Error("resourceManagerEndpointUrl is a required parameter when environment is defined.");
|
||||
}
|
||||
console.log(`Unregistering cloud: "${environment}" first if it exists`);
|
||||
try {
|
||||
yield executeAzCliCommand(`cloud set -n AzureCloud`, true);
|
||||
yield executeAzCliCommand(`cloud unregister -n "${environment}"`, false);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`Ignore cloud not registered error: "${error}"`);
|
||||
}
|
||||
console.log(`Registering cloud: "${environment}" with ARM endpoint: "${resourceManagerEndpointUrl}"`);
|
||||
try {
|
||||
let baseUri = resourceManagerEndpointUrl;
|
||||
if (baseUri.endsWith('/')) {
|
||||
baseUri = baseUri.substring(0, baseUri.length - 1); // need to remove trailing / from resourceManagerEndpointUrl to correctly derive suffixes below
|
||||
}
|
||||
let suffixKeyvault = ".vault" + baseUri.substring(baseUri.indexOf('.')); // keyvault suffix starts with .
|
||||
let suffixStorage = baseUri.substring(baseUri.indexOf('.') + 1); // storage suffix starts without .
|
||||
let profileVersion = "2019-03-01-hybrid";
|
||||
yield executeAzCliCommand(`cloud register -n "${environment}" --endpoint-resource-manager "${resourceManagerEndpointUrl}" --suffix-keyvault-dns "${suffixKeyvault}" --suffix-storage-endpoint "${suffixStorage}" --profile "${profileVersion}"`, false);
|
||||
}
|
||||
catch (error) {
|
||||
core.error(`Error while trying to register cloud "${environment}": "${error}"`);
|
||||
}
|
||||
console.log(`Done registering cloud: "${environment}"`);
|
||||
}
|
||||
yield executeAzCliCommand(`cloud set -n "${environment}"`, false);
|
||||
console.log(`Done setting cloud: "${environment}"`);
|
||||
// Attempting Az cli login
|
||||
if (allowNoSubscriptionsLogin) {
|
||||
let args = [
|
||||
"--allow-no-subscriptions",
|
||||
"--service-principal",
|
||||
"-u", servicePrincipalId,
|
||||
"-p", servicePrincipalKey,
|
||||
"--tenant", tenantId
|
||||
];
|
||||
yield executeAzCliCommand(`login`, true, {}, args);
|
||||
}
|
||||
else {
|
||||
let args = [
|
||||
"--service-principal",
|
||||
"-u", servicePrincipalId,
|
||||
"-p", servicePrincipalKey,
|
||||
"--tenant", tenantId
|
||||
];
|
||||
yield executeAzCliCommand(`login`, true, {}, args);
|
||||
args = [
|
||||
"--subscription",
|
||||
subscriptionId
|
||||
];
|
||||
yield executeAzCliCommand(`account set`, true, {}, args);
|
||||
}
|
||||
isAzCLISuccess = true;
|
||||
if (enableAzPSSession) {
|
||||
// Attempting Az PS login
|
||||
console.log(`Running Azure PS Login`);
|
||||
const spnlogin = new ServicePrincipalLogin_1.ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin, environment, resourceManagerEndpointUrl);
|
||||
yield spnlogin.initialize();
|
||||
yield spnlogin.login();
|
||||
}
|
||||
console.log("Login successful.");
|
||||
}
|
||||
catch (error) {
|
||||
if (!isAzCLISuccess) {
|
||||
core.error("Az CLI Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows");
|
||||
}
|
||||
else {
|
||||
core.error(`Azure PowerShell Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows"`);
|
||||
}
|
||||
core.setFailed(error);
|
||||
}
|
||||
finally {
|
||||
// Reset AZURE_HTTP_USER_AGENT
|
||||
core.exportVariable('AZURE_HTTP_USER_AGENT', prefix);
|
||||
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azPSHostEnv);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.main = main;
|
||||
function executeAzCliCommand(command, silent, execOptions = {}, args = []) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
execOptions.silent = !!silent;
|
||||
try {
|
||||
yield exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.executeAzCliCommand = executeAzCliCommand;
|
||||
main();
|
15
node_modules/.bin/escodegen
generated
vendored
Normal file
15
node_modules/.bin/escodegen
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../escodegen/bin/escodegen.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../escodegen/bin/escodegen.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
17
node_modules/.bin/escodegen.cmd
generated
vendored
Normal file
17
node_modules/.bin/escodegen.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\escodegen\bin\escodegen.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
18
node_modules/.bin/escodegen.ps1
generated
vendored
Normal file
18
node_modules/.bin/escodegen.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../escodegen/bin/escodegen.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../escodegen/bin/escodegen.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
15
node_modules/.bin/esgenerate
generated
vendored
Normal file
15
node_modules/.bin/esgenerate
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../escodegen/bin/esgenerate.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../escodegen/bin/esgenerate.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
17
node_modules/.bin/esgenerate.cmd
generated
vendored
Normal file
17
node_modules/.bin/esgenerate.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\escodegen\bin\esgenerate.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
18
node_modules/.bin/esgenerate.ps1
generated
vendored
Normal file
18
node_modules/.bin/esgenerate.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../escodegen/bin/esgenerate.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../escodegen/bin/esgenerate.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
24
node_modules/actions-secret-parser/index.d.ts
generated
vendored
Normal file
24
node_modules/actions-secret-parser/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
export declare enum FormatType {
|
||||
"JSON" = 0,
|
||||
"XML" = 1
|
||||
}
|
||||
/**
|
||||
* Takes content as string and format type (xml, json).
|
||||
* Exposes getSecret method to get value of specific secret in object and set it as secret.
|
||||
*/
|
||||
export declare class SecretParser {
|
||||
private dom;
|
||||
private contentType;
|
||||
constructor(content: string, contentType: FormatType);
|
||||
/**
|
||||
*
|
||||
* @param key jsonpath or xpath depending on content type
|
||||
* @param isSecret should the value parsed be a secret. Deafult: true
|
||||
* @param variableName optional. If provided value will be exported with this variable name
|
||||
* @returns a string value or empty string if key not found
|
||||
*/
|
||||
getSecret(key: string, isSecret?: boolean, variableName?: string): string;
|
||||
private extractJsonPath;
|
||||
private extractXmlPath;
|
||||
private handleSecret;
|
||||
}
|
91
node_modules/actions-secret-parser/index.js
generated
vendored
Normal file
91
node_modules/actions-secret-parser/index.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var core = require('@actions/core');
|
||||
var jp = require('jsonpath');
|
||||
var xpath = require('xpath');
|
||||
var domParser = require('xmldom').DOMParser;
|
||||
var FormatType;
|
||||
(function (FormatType) {
|
||||
FormatType[FormatType["JSON"] = 0] = "JSON";
|
||||
FormatType[FormatType["XML"] = 1] = "XML";
|
||||
})(FormatType = exports.FormatType || (exports.FormatType = {}));
|
||||
/**
|
||||
* Takes content as string and format type (xml, json).
|
||||
* Exposes getSecret method to get value of specific secret in object and set it as secret.
|
||||
*/
|
||||
class SecretParser {
|
||||
constructor(content, contentType) {
|
||||
switch (contentType) {
|
||||
case FormatType.JSON:
|
||||
try {
|
||||
this.dom = JSON.parse(content);
|
||||
}
|
||||
catch (ex) {
|
||||
throw new Error('Content is not a valid JSON object');
|
||||
}
|
||||
break;
|
||||
case FormatType.XML:
|
||||
try {
|
||||
this.dom = new domParser().parseFromString(content);
|
||||
}
|
||||
catch (ex) {
|
||||
throw new Error('Content is not a valid XML object');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Given format: ${contentType} is not supported. Valid options are JSON, XML.`);
|
||||
}
|
||||
this.contentType = contentType;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param key jsonpath or xpath depending on content type
|
||||
* @param isSecret should the value parsed be a secret. Deafult: true
|
||||
* @param variableName optional. If provided value will be exported with this variable name
|
||||
* @returns a string value or empty string if key not found
|
||||
*/
|
||||
getSecret(key, isSecret = true, variableName) {
|
||||
let value = "";
|
||||
switch (this.contentType) {
|
||||
case FormatType.JSON:
|
||||
value = this.extractJsonPath(key, isSecret, variableName);
|
||||
break;
|
||||
case FormatType.XML:
|
||||
value = this.extractXmlPath(key, isSecret, variableName);
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
extractJsonPath(key, isSecret = false, variableName) {
|
||||
let value = jp.query(this.dom, key);
|
||||
if (value.length == 0) {
|
||||
core.debug("Cannot find key: " + key);
|
||||
return "";
|
||||
}
|
||||
else if (value.length > 1) {
|
||||
core.debug("Multiple values found for key: " + key + ". Please give jsonPath which points to a single value.");
|
||||
return "";
|
||||
}
|
||||
return this.handleSecret(key, value[0], isSecret, variableName);
|
||||
}
|
||||
extractXmlPath(key, isSecret = false, variableName) {
|
||||
let value = xpath.select("string(" + key + ")", this.dom);
|
||||
return this.handleSecret(key, value, isSecret, variableName);
|
||||
}
|
||||
handleSecret(key, value, isSecret, variableName) {
|
||||
if (!!value) {
|
||||
if (isSecret) {
|
||||
core.setSecret(value);
|
||||
}
|
||||
if (!!variableName) {
|
||||
core.exportVariable(variableName, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
core.debug("Cannot find key: " + key);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.SecretParser = SecretParser;
|
63
node_modules/actions-secret-parser/package.json
generated
vendored
Normal file
63
node_modules/actions-secret-parser/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"_from": "actions-secret-parser",
|
||||
"_id": "actions-secret-parser@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-+iGlMSsE/cbxDaEZlqR0NUjn35DckMYsdYFwVeZ7JRbtyO/AiBKnaScKkzkHSoiZ4nEPTdIHtMpRGVgoeVYX+A==",
|
||||
"_location": "/actions-secret-parser",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "actions-secret-parser",
|
||||
"name": "actions-secret-parser",
|
||||
"escapedName": "actions-secret-parser",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/actions-secret-parser/-/actions-secret-parser-1.0.3.tgz",
|
||||
"_shasum": "2574adaab76103ed0b3579546d85e0928c354034",
|
||||
"_spec": "actions-secret-parser",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules",
|
||||
"author": {
|
||||
"name": "Sumiran Aggarwal",
|
||||
"email": "suaggar@microsoft.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/pipelines-appservice-lib/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.1.3",
|
||||
"jsonpath": "^1.0.2",
|
||||
"xmldom": "^0.1.27",
|
||||
"xpath": "0.0.27"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Parse and set repository secrets",
|
||||
"devDependencies": {
|
||||
"typescript": "^3.6.3"
|
||||
},
|
||||
"homepage": "https://github.com/Microsoft/pipelines-appservice-lib/tree/master/packages/utility",
|
||||
"keywords": [
|
||||
"secret",
|
||||
"actions"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "actions-secret-parser",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Microsoft/pipelines-appservice-lib.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"copypackage": "copy package.json lib",
|
||||
"dist": "npm run build && npm run copypackage && cd lib && npm publish"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
1
node_modules/deep-is/.npmignore
generated
vendored
Normal file
1
node_modules/deep-is/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
6
node_modules/deep-is/.travis.yml
generated
vendored
Normal file
6
node_modules/deep-is/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
||||
- 0.8
|
||||
- 0.10
|
22
node_modules/deep-is/LICENSE
generated
vendored
Normal file
22
node_modules/deep-is/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012, 2013 Thorsten Lorenz <thlorenz@gmx.de>
|
||||
Copyright (c) 2012 James Halliday <mail@substack.net>
|
||||
Copyright (c) 2009 Thomas Robinson <280north.com>
|
||||
|
||||
This software is released under the MIT license:
|
||||
|
||||
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.
|
70
node_modules/deep-is/README.markdown
generated
vendored
Normal file
70
node_modules/deep-is/README.markdown
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
deep-is
|
||||
==========
|
||||
|
||||
Node's `assert.deepEqual() algorithm` as a standalone module. Exactly like
|
||||
[deep-equal](https://github.com/substack/node-deep-equal) except for the fact that `deepEqual(NaN, NaN) === true`.
|
||||
|
||||
This module is around [5 times faster](https://gist.github.com/2790507)
|
||||
than wrapping `assert.deepEqual()` in a `try/catch`.
|
||||
|
||||
[](http://ci.testling.com/thlorenz/deep-is)
|
||||
|
||||
[](http://travis-ci.org/thlorenz/deep-is)
|
||||
|
||||
example
|
||||
=======
|
||||
|
||||
``` js
|
||||
var equal = require('deep-is');
|
||||
console.dir([
|
||||
equal(
|
||||
{ a : [ 2, 3 ], b : [ 4 ] },
|
||||
{ a : [ 2, 3 ], b : [ 4 ] }
|
||||
),
|
||||
equal(
|
||||
{ x : 5, y : [6] },
|
||||
{ x : 5, y : 6 }
|
||||
)
|
||||
]);
|
||||
```
|
||||
|
||||
methods
|
||||
=======
|
||||
|
||||
var deepIs = require('deep-is')
|
||||
|
||||
deepIs(a, b)
|
||||
---------------
|
||||
|
||||
Compare objects `a` and `b`, returning whether they are equal according to a
|
||||
recursive equality algorithm.
|
||||
|
||||
install
|
||||
=======
|
||||
|
||||
With [npm](http://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install deep-is
|
||||
```
|
||||
|
||||
test
|
||||
====
|
||||
|
||||
With [npm](http://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
license
|
||||
=======
|
||||
|
||||
Copyright (c) 2012, 2013 Thorsten Lorenz <thlorenz@gmx.de>
|
||||
Copyright (c) 2012 James Halliday <mail@substack.net>
|
||||
|
||||
Derived largely from node's assert module, which has the copyright statement:
|
||||
|
||||
Copyright (c) 2009 Thomas Robinson <280north.com>
|
||||
|
||||
Released under the MIT license, see LICENSE for details.
|
11
node_modules/deep-is/example/cmp.js
generated
vendored
Normal file
11
node_modules/deep-is/example/cmp.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
var equal = require('../');
|
||||
console.dir([
|
||||
equal(
|
||||
{ a : [ 2, 3 ], b : [ 4 ] },
|
||||
{ a : [ 2, 3 ], b : [ 4 ] }
|
||||
),
|
||||
equal(
|
||||
{ x : 5, y : [6] },
|
||||
{ x : 5, y : 6 }
|
||||
)
|
||||
]);
|
102
node_modules/deep-is/index.js
generated
vendored
Normal file
102
node_modules/deep-is/index.js
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
var pSlice = Array.prototype.slice;
|
||||
var Object_keys = typeof Object.keys === 'function'
|
||||
? Object.keys
|
||||
: function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) keys.push(key);
|
||||
return keys;
|
||||
}
|
||||
;
|
||||
|
||||
var deepEqual = module.exports = function (actual, expected) {
|
||||
// enforce Object.is +0 !== -0
|
||||
if (actual === 0 && expected === 0) {
|
||||
return areZerosEqual(actual, expected);
|
||||
|
||||
// 7.1. All identical values are equivalent, as determined by ===.
|
||||
} else if (actual === expected) {
|
||||
return true;
|
||||
|
||||
} else if (actual instanceof Date && expected instanceof Date) {
|
||||
return actual.getTime() === expected.getTime();
|
||||
|
||||
} else if (isNumberNaN(actual)) {
|
||||
return isNumberNaN(expected);
|
||||
|
||||
// 7.3. Other pairs that do not both pass typeof value == 'object',
|
||||
// equivalence is determined by ==.
|
||||
} else if (typeof actual != 'object' && typeof expected != 'object') {
|
||||
return actual == expected;
|
||||
|
||||
// 7.4. For all other Object pairs, including Array objects, equivalence is
|
||||
// determined by having the same number of owned properties (as verified
|
||||
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
||||
// (although not necessarily the same order), equivalent values for every
|
||||
// corresponding key, and an identical 'prototype' property. Note: this
|
||||
// accounts for both named and indexed properties on Arrays.
|
||||
} else {
|
||||
return objEquiv(actual, expected);
|
||||
}
|
||||
};
|
||||
|
||||
function isUndefinedOrNull(value) {
|
||||
return value === null || value === undefined;
|
||||
}
|
||||
|
||||
function isArguments(object) {
|
||||
return Object.prototype.toString.call(object) == '[object Arguments]';
|
||||
}
|
||||
|
||||
function isNumberNaN(value) {
|
||||
// NaN === NaN -> false
|
||||
return typeof value == 'number' && value !== value;
|
||||
}
|
||||
|
||||
function areZerosEqual(zeroA, zeroB) {
|
||||
// (1 / +0|0) -> Infinity, but (1 / -0) -> -Infinity and (Infinity !== -Infinity)
|
||||
return (1 / zeroA) === (1 / zeroB);
|
||||
}
|
||||
|
||||
function objEquiv(a, b) {
|
||||
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
|
||||
return false;
|
||||
|
||||
// an identical 'prototype' property.
|
||||
if (a.prototype !== b.prototype) return false;
|
||||
//~~~I've managed to break Object.keys through screwy arguments passing.
|
||||
// Converting to array solves the problem.
|
||||
if (isArguments(a)) {
|
||||
if (!isArguments(b)) {
|
||||
return false;
|
||||
}
|
||||
a = pSlice.call(a);
|
||||
b = pSlice.call(b);
|
||||
return deepEqual(a, b);
|
||||
}
|
||||
try {
|
||||
var ka = Object_keys(a),
|
||||
kb = Object_keys(b),
|
||||
key, i;
|
||||
} catch (e) {//happens when one is a string literal and the other isn't
|
||||
return false;
|
||||
}
|
||||
// having the same number of owned properties (keys incorporates
|
||||
// hasOwnProperty)
|
||||
if (ka.length != kb.length)
|
||||
return false;
|
||||
//the same set of keys (although not necessarily the same order),
|
||||
ka.sort();
|
||||
kb.sort();
|
||||
//~~~cheap key test
|
||||
for (i = ka.length - 1; i >= 0; i--) {
|
||||
if (ka[i] != kb[i])
|
||||
return false;
|
||||
}
|
||||
//equivalent values for every corresponding key, and
|
||||
//~~~possibly expensive deep test
|
||||
for (i = ka.length - 1; i >= 0; i--) {
|
||||
key = ka[i];
|
||||
if (!deepEqual(a[key], b[key])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
90
node_modules/deep-is/package.json
generated
vendored
Normal file
90
node_modules/deep-is/package.json
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"_from": "deep-is@~0.1.3",
|
||||
"_id": "deep-is@0.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
|
||||
"_location": "/deep-is",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "deep-is@~0.1.3",
|
||||
"name": "deep-is",
|
||||
"escapedName": "deep-is",
|
||||
"rawSpec": "~0.1.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~0.1.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/optionator"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
|
||||
"_shasum": "b369d6fb5dbc13eecf524f91b070feedc357cf34",
|
||||
"_spec": "deep-is@~0.1.3",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules\\optionator",
|
||||
"author": {
|
||||
"name": "Thorsten Lorenz",
|
||||
"email": "thlorenz@gmx.de",
|
||||
"url": "http://thlorenz.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/thlorenz/deep-is/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "node's assert.deepEqual algorithm except for NaN being equal to NaN",
|
||||
"devDependencies": {
|
||||
"tape": "~1.0.2"
|
||||
},
|
||||
"directories": {
|
||||
"lib": ".",
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/thlorenz/deep-is#readme",
|
||||
"keywords": [
|
||||
"equality",
|
||||
"equal",
|
||||
"compare"
|
||||
],
|
||||
"license": {
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/thlorenz/deep-is/blob/master/LICENSE"
|
||||
},
|
||||
"main": "index.js",
|
||||
"name": "deep-is",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/thlorenz/deep-is.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": {
|
||||
"ie": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9
|
||||
],
|
||||
"ff": [
|
||||
3.5,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"chrome": [
|
||||
10,
|
||||
22
|
||||
],
|
||||
"safari": [
|
||||
5.1
|
||||
],
|
||||
"opera": [
|
||||
12
|
||||
]
|
||||
}
|
||||
},
|
||||
"version": "0.1.3"
|
||||
}
|
16
node_modules/deep-is/test/NaN.js
generated
vendored
Normal file
16
node_modules/deep-is/test/NaN.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
var test = require('tape');
|
||||
var equal = require('../');
|
||||
|
||||
test('NaN and 0 values', function (t) {
|
||||
t.ok(equal(NaN, NaN));
|
||||
t.notOk(equal(0, NaN));
|
||||
t.ok(equal(0, 0));
|
||||
t.notOk(equal(0, 1));
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('nested NaN values', function (t) {
|
||||
t.ok(equal([ NaN, 1, NaN ], [ NaN, 1, NaN ]));
|
||||
t.end();
|
||||
});
|
23
node_modules/deep-is/test/cmp.js
generated
vendored
Normal file
23
node_modules/deep-is/test/cmp.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
var test = require('tape');
|
||||
var equal = require('../');
|
||||
|
||||
test('equal', function (t) {
|
||||
t.ok(equal(
|
||||
{ a : [ 2, 3 ], b : [ 4 ] },
|
||||
{ a : [ 2, 3 ], b : [ 4 ] }
|
||||
));
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('not equal', function (t) {
|
||||
t.notOk(equal(
|
||||
{ x : 5, y : [6] },
|
||||
{ x : 5, y : 6 }
|
||||
));
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('nested nulls', function (t) {
|
||||
t.ok(equal([ null, null, null ], [ null, null, null ]));
|
||||
t.end();
|
||||
});
|
15
node_modules/deep-is/test/neg-vs-pos-0.js
generated
vendored
Normal file
15
node_modules/deep-is/test/neg-vs-pos-0.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
var test = require('tape');
|
||||
var equal = require('../');
|
||||
|
||||
test('0 values', function (t) {
|
||||
t.ok(equal( 0, 0), ' 0 === 0');
|
||||
t.ok(equal( 0, +0), ' 0 === +0');
|
||||
t.ok(equal(+0, +0), '+0 === +0');
|
||||
t.ok(equal(-0, -0), '-0 === -0');
|
||||
|
||||
t.notOk(equal(-0, 0), '-0 !== 0');
|
||||
t.notOk(equal(-0, +0), '-0 !== +0');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
21
node_modules/escodegen/LICENSE.BSD
generated
vendored
Normal file
21
node_modules/escodegen/LICENSE.BSD
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Copyright (C) 2012 Yusuke Suzuki (twitter: @Constellation) and other contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
84
node_modules/escodegen/README.md
generated
vendored
Normal file
84
node_modules/escodegen/README.md
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
## Escodegen
|
||||
[](http://badge.fury.io/js/escodegen)
|
||||
[](http://travis-ci.org/estools/escodegen)
|
||||
[](https://david-dm.org/estools/escodegen)
|
||||
[](https://david-dm.org/estools/escodegen#info=devDependencies)
|
||||
|
||||
Escodegen ([escodegen](http://github.com/estools/escodegen)) is an
|
||||
[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||
(also popularly known as [JavaScript](http://en.wikipedia.org/wiki/JavaScript))
|
||||
code generator from [Mozilla's Parser API](https://developer.mozilla.org/en/SpiderMonkey/Parser_API)
|
||||
AST. See the [online generator](https://estools.github.io/escodegen/demo/index.html)
|
||||
for a demo.
|
||||
|
||||
|
||||
### Install
|
||||
|
||||
Escodegen can be used in a web browser:
|
||||
|
||||
<script src="escodegen.browser.js"></script>
|
||||
|
||||
escodegen.browser.js can be found in tagged revisions on GitHub.
|
||||
|
||||
Or in a Node.js application via npm:
|
||||
|
||||
npm install escodegen
|
||||
|
||||
### Usage
|
||||
|
||||
A simple example: the program
|
||||
|
||||
escodegen.generate({
|
||||
type: 'BinaryExpression',
|
||||
operator: '+',
|
||||
left: { type: 'Literal', value: 40 },
|
||||
right: { type: 'Literal', value: 2 }
|
||||
});
|
||||
|
||||
produces the string `'40 + 2'`.
|
||||
|
||||
See the [API page](https://github.com/estools/escodegen/wiki/API) for
|
||||
options. To run the tests, execute `npm test` in the root directory.
|
||||
|
||||
### Building browser bundle / minified browser bundle
|
||||
|
||||
At first, execute `npm install` to install the all dev dependencies.
|
||||
After that,
|
||||
|
||||
npm run-script build
|
||||
|
||||
will generate `escodegen.browser.js`, which can be used in browser environments.
|
||||
|
||||
And,
|
||||
|
||||
npm run-script build-min
|
||||
|
||||
will generate the minified file `escodegen.browser.min.js`.
|
||||
|
||||
### License
|
||||
|
||||
#### Escodegen
|
||||
|
||||
Copyright (C) 2012 [Yusuke Suzuki](http://github.com/Constellation)
|
||||
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2626
node_modules/escodegen/escodegen.js
generated
vendored
Normal file
2626
node_modules/escodegen/escodegen.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
90
node_modules/escodegen/package.json
generated
vendored
Normal file
90
node_modules/escodegen/package.json
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"_from": "escodegen@^1.8.1",
|
||||
"_id": "escodegen@1.14.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==",
|
||||
"_location": "/escodegen",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "escodegen@^1.8.1",
|
||||
"name": "escodegen",
|
||||
"escapedName": "escodegen",
|
||||
"rawSpec": "^1.8.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.8.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/static-eval"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz",
|
||||
"_shasum": "4e7b81fba61581dc97582ed78cab7f0e8d63f503",
|
||||
"_spec": "escodegen@^1.8.1",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules\\static-eval",
|
||||
"bin": {
|
||||
"esgenerate": "bin/esgenerate.js",
|
||||
"escodegen": "bin/escodegen.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/estools/escodegen/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"esprima": "^4.0.1",
|
||||
"estraverse": "^4.2.0",
|
||||
"esutils": "^2.0.2",
|
||||
"optionator": "^0.8.1",
|
||||
"source-map": "~0.6.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "ECMAScript code generator",
|
||||
"devDependencies": {
|
||||
"acorn": "^7.1.0",
|
||||
"bluebird": "^3.4.7",
|
||||
"bower-registry-client": "^1.0.0",
|
||||
"chai": "^3.5.0",
|
||||
"commonjs-everywhere": "^0.9.7",
|
||||
"gulp": "^3.8.10",
|
||||
"gulp-eslint": "^3.0.1",
|
||||
"gulp-mocha": "^3.0.1",
|
||||
"semver": "^5.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE.BSD",
|
||||
"README.md",
|
||||
"bin",
|
||||
"escodegen.js",
|
||||
"package.json"
|
||||
],
|
||||
"homepage": "http://github.com/estools/escodegen",
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "escodegen.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Yusuke Suzuki",
|
||||
"email": "utatane.tea@gmail.com",
|
||||
"url": "http://github.com/Constellation"
|
||||
}
|
||||
],
|
||||
"name": "escodegen",
|
||||
"optionalDependencies": {
|
||||
"source-map": "~0.6.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/estools/escodegen.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "cjsify -a path: tools/entry-point.js > escodegen.browser.js",
|
||||
"build-min": "cjsify -ma path: tools/entry-point.js > escodegen.browser.min.js",
|
||||
"lint": "gulp lint",
|
||||
"release": "node tools/release.js",
|
||||
"test": "gulp travis",
|
||||
"unit-test": "gulp test"
|
||||
},
|
||||
"version": "1.14.3"
|
||||
}
|
16
node_modules/estraverse/.jshintrc
generated
vendored
Normal file
16
node_modules/estraverse/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"eqnull": true,
|
||||
"latedef": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"quotmark": "single",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
|
||||
"node": true
|
||||
}
|
19
node_modules/estraverse/LICENSE.BSD
generated
vendored
Normal file
19
node_modules/estraverse/LICENSE.BSD
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
153
node_modules/estraverse/README.md
generated
vendored
Normal file
153
node_modules/estraverse/README.md
generated
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
### Estraverse [](http://travis-ci.org/estools/estraverse)
|
||||
|
||||
Estraverse ([estraverse](http://github.com/estools/estraverse)) is
|
||||
[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||
traversal functions from [esmangle project](http://github.com/estools/esmangle).
|
||||
|
||||
### Documentation
|
||||
|
||||
You can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage).
|
||||
|
||||
### Example Usage
|
||||
|
||||
The following code will output all variables declared at the root of a file.
|
||||
|
||||
```javascript
|
||||
estraverse.traverse(ast, {
|
||||
enter: function (node, parent) {
|
||||
if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')
|
||||
return estraverse.VisitorOption.Skip;
|
||||
},
|
||||
leave: function (node, parent) {
|
||||
if (node.type == 'VariableDeclarator')
|
||||
console.log(node.id.name);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
We can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.
|
||||
|
||||
```javascript
|
||||
estraverse.traverse(ast, {
|
||||
enter: function (node) {
|
||||
this.break();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
And estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.
|
||||
|
||||
```javascript
|
||||
result = estraverse.replace(tree, {
|
||||
enter: function (node) {
|
||||
// Replace it with replaced.
|
||||
if (node.type === 'Literal')
|
||||
return replaced;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
By passing `visitor.keys` mapping, we can extend estraverse traversing functionality.
|
||||
|
||||
```javascript
|
||||
// This tree contains a user-defined `TestExpression` node.
|
||||
var tree = {
|
||||
type: 'TestExpression',
|
||||
|
||||
// This 'argument' is the property containing the other **node**.
|
||||
argument: {
|
||||
type: 'Literal',
|
||||
value: 20
|
||||
},
|
||||
|
||||
// This 'extended' is the property not containing the other **node**.
|
||||
extended: true
|
||||
};
|
||||
estraverse.traverse(tree, {
|
||||
enter: function (node) { },
|
||||
|
||||
// Extending the existing traversing rules.
|
||||
keys: {
|
||||
// TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ]
|
||||
TestExpression: ['argument']
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
By passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes.
|
||||
|
||||
```javascript
|
||||
// This tree contains a user-defined `TestExpression` node.
|
||||
var tree = {
|
||||
type: 'TestExpression',
|
||||
|
||||
// This 'argument' is the property containing the other **node**.
|
||||
argument: {
|
||||
type: 'Literal',
|
||||
value: 20
|
||||
},
|
||||
|
||||
// This 'extended' is the property not containing the other **node**.
|
||||
extended: true
|
||||
};
|
||||
estraverse.traverse(tree, {
|
||||
enter: function (node) { },
|
||||
|
||||
// Iterating the child **nodes** of unknown nodes.
|
||||
fallback: 'iteration'
|
||||
});
|
||||
```
|
||||
|
||||
When `visitor.fallback` is a function, we can determine which keys to visit on each node.
|
||||
|
||||
```javascript
|
||||
// This tree contains a user-defined `TestExpression` node.
|
||||
var tree = {
|
||||
type: 'TestExpression',
|
||||
|
||||
// This 'argument' is the property containing the other **node**.
|
||||
argument: {
|
||||
type: 'Literal',
|
||||
value: 20
|
||||
},
|
||||
|
||||
// This 'extended' is the property not containing the other **node**.
|
||||
extended: true
|
||||
};
|
||||
estraverse.traverse(tree, {
|
||||
enter: function (node) { },
|
||||
|
||||
// Skip the `argument` property of each node
|
||||
fallback: function(node) {
|
||||
return Object.keys(node).filter(function(key) {
|
||||
return key !== 'argument';
|
||||
});
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### License
|
||||
|
||||
Copyright (C) 2012-2016 [Yusuke Suzuki](http://github.com/Constellation)
|
||||
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
782
node_modules/estraverse/estraverse.js
generated
vendored
Normal file
782
node_modules/estraverse/estraverse.js
generated
vendored
Normal file
@ -0,0 +1,782 @@
|
||||
/*
|
||||
Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*jslint vars:false, bitwise:true*/
|
||||
/*jshint indent:4*/
|
||||
/*global exports:true*/
|
||||
(function clone(exports) {
|
||||
'use strict';
|
||||
|
||||
var Syntax,
|
||||
VisitorOption,
|
||||
VisitorKeys,
|
||||
BREAK,
|
||||
SKIP,
|
||||
REMOVE;
|
||||
|
||||
function deepCopy(obj) {
|
||||
var ret = {}, key, val;
|
||||
for (key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
val = obj[key];
|
||||
if (typeof val === 'object' && val !== null) {
|
||||
ret[key] = deepCopy(val);
|
||||
} else {
|
||||
ret[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// based on LLVM libc++ upper_bound / lower_bound
|
||||
// MIT License
|
||||
|
||||
function upperBound(array, func) {
|
||||
var diff, len, i, current;
|
||||
|
||||
len = array.length;
|
||||
i = 0;
|
||||
|
||||
while (len) {
|
||||
diff = len >>> 1;
|
||||
current = i + diff;
|
||||
if (func(array[current])) {
|
||||
len = diff;
|
||||
} else {
|
||||
i = current + 1;
|
||||
len -= diff + 1;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
Syntax = {
|
||||
AssignmentExpression: 'AssignmentExpression',
|
||||
AssignmentPattern: 'AssignmentPattern',
|
||||
ArrayExpression: 'ArrayExpression',
|
||||
ArrayPattern: 'ArrayPattern',
|
||||
ArrowFunctionExpression: 'ArrowFunctionExpression',
|
||||
AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
|
||||
BlockStatement: 'BlockStatement',
|
||||
BinaryExpression: 'BinaryExpression',
|
||||
BreakStatement: 'BreakStatement',
|
||||
CallExpression: 'CallExpression',
|
||||
CatchClause: 'CatchClause',
|
||||
ClassBody: 'ClassBody',
|
||||
ClassDeclaration: 'ClassDeclaration',
|
||||
ClassExpression: 'ClassExpression',
|
||||
ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
|
||||
ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
|
||||
ConditionalExpression: 'ConditionalExpression',
|
||||
ContinueStatement: 'ContinueStatement',
|
||||
DebuggerStatement: 'DebuggerStatement',
|
||||
DirectiveStatement: 'DirectiveStatement',
|
||||
DoWhileStatement: 'DoWhileStatement',
|
||||
EmptyStatement: 'EmptyStatement',
|
||||
ExportAllDeclaration: 'ExportAllDeclaration',
|
||||
ExportDefaultDeclaration: 'ExportDefaultDeclaration',
|
||||
ExportNamedDeclaration: 'ExportNamedDeclaration',
|
||||
ExportSpecifier: 'ExportSpecifier',
|
||||
ExpressionStatement: 'ExpressionStatement',
|
||||
ForStatement: 'ForStatement',
|
||||
ForInStatement: 'ForInStatement',
|
||||
ForOfStatement: 'ForOfStatement',
|
||||
FunctionDeclaration: 'FunctionDeclaration',
|
||||
FunctionExpression: 'FunctionExpression',
|
||||
GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
|
||||
Identifier: 'Identifier',
|
||||
IfStatement: 'IfStatement',
|
||||
ImportExpression: 'ImportExpression',
|
||||
ImportDeclaration: 'ImportDeclaration',
|
||||
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
|
||||
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
|
||||
ImportSpecifier: 'ImportSpecifier',
|
||||
Literal: 'Literal',
|
||||
LabeledStatement: 'LabeledStatement',
|
||||
LogicalExpression: 'LogicalExpression',
|
||||
MemberExpression: 'MemberExpression',
|
||||
MetaProperty: 'MetaProperty',
|
||||
MethodDefinition: 'MethodDefinition',
|
||||
ModuleSpecifier: 'ModuleSpecifier',
|
||||
NewExpression: 'NewExpression',
|
||||
ObjectExpression: 'ObjectExpression',
|
||||
ObjectPattern: 'ObjectPattern',
|
||||
Program: 'Program',
|
||||
Property: 'Property',
|
||||
RestElement: 'RestElement',
|
||||
ReturnStatement: 'ReturnStatement',
|
||||
SequenceExpression: 'SequenceExpression',
|
||||
SpreadElement: 'SpreadElement',
|
||||
Super: 'Super',
|
||||
SwitchStatement: 'SwitchStatement',
|
||||
SwitchCase: 'SwitchCase',
|
||||
TaggedTemplateExpression: 'TaggedTemplateExpression',
|
||||
TemplateElement: 'TemplateElement',
|
||||
TemplateLiteral: 'TemplateLiteral',
|
||||
ThisExpression: 'ThisExpression',
|
||||
ThrowStatement: 'ThrowStatement',
|
||||
TryStatement: 'TryStatement',
|
||||
UnaryExpression: 'UnaryExpression',
|
||||
UpdateExpression: 'UpdateExpression',
|
||||
VariableDeclaration: 'VariableDeclaration',
|
||||
VariableDeclarator: 'VariableDeclarator',
|
||||
WhileStatement: 'WhileStatement',
|
||||
WithStatement: 'WithStatement',
|
||||
YieldExpression: 'YieldExpression'
|
||||
};
|
||||
|
||||
VisitorKeys = {
|
||||
AssignmentExpression: ['left', 'right'],
|
||||
AssignmentPattern: ['left', 'right'],
|
||||
ArrayExpression: ['elements'],
|
||||
ArrayPattern: ['elements'],
|
||||
ArrowFunctionExpression: ['params', 'body'],
|
||||
AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
|
||||
BlockStatement: ['body'],
|
||||
BinaryExpression: ['left', 'right'],
|
||||
BreakStatement: ['label'],
|
||||
CallExpression: ['callee', 'arguments'],
|
||||
CatchClause: ['param', 'body'],
|
||||
ClassBody: ['body'],
|
||||
ClassDeclaration: ['id', 'superClass', 'body'],
|
||||
ClassExpression: ['id', 'superClass', 'body'],
|
||||
ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
|
||||
ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
|
||||
ConditionalExpression: ['test', 'consequent', 'alternate'],
|
||||
ContinueStatement: ['label'],
|
||||
DebuggerStatement: [],
|
||||
DirectiveStatement: [],
|
||||
DoWhileStatement: ['body', 'test'],
|
||||
EmptyStatement: [],
|
||||
ExportAllDeclaration: ['source'],
|
||||
ExportDefaultDeclaration: ['declaration'],
|
||||
ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
|
||||
ExportSpecifier: ['exported', 'local'],
|
||||
ExpressionStatement: ['expression'],
|
||||
ForStatement: ['init', 'test', 'update', 'body'],
|
||||
ForInStatement: ['left', 'right', 'body'],
|
||||
ForOfStatement: ['left', 'right', 'body'],
|
||||
FunctionDeclaration: ['id', 'params', 'body'],
|
||||
FunctionExpression: ['id', 'params', 'body'],
|
||||
GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
|
||||
Identifier: [],
|
||||
IfStatement: ['test', 'consequent', 'alternate'],
|
||||
ImportExpression: ['source'],
|
||||
ImportDeclaration: ['specifiers', 'source'],
|
||||
ImportDefaultSpecifier: ['local'],
|
||||
ImportNamespaceSpecifier: ['local'],
|
||||
ImportSpecifier: ['imported', 'local'],
|
||||
Literal: [],
|
||||
LabeledStatement: ['label', 'body'],
|
||||
LogicalExpression: ['left', 'right'],
|
||||
MemberExpression: ['object', 'property'],
|
||||
MetaProperty: ['meta', 'property'],
|
||||
MethodDefinition: ['key', 'value'],
|
||||
ModuleSpecifier: [],
|
||||
NewExpression: ['callee', 'arguments'],
|
||||
ObjectExpression: ['properties'],
|
||||
ObjectPattern: ['properties'],
|
||||
Program: ['body'],
|
||||
Property: ['key', 'value'],
|
||||
RestElement: [ 'argument' ],
|
||||
ReturnStatement: ['argument'],
|
||||
SequenceExpression: ['expressions'],
|
||||
SpreadElement: ['argument'],
|
||||
Super: [],
|
||||
SwitchStatement: ['discriminant', 'cases'],
|
||||
SwitchCase: ['test', 'consequent'],
|
||||
TaggedTemplateExpression: ['tag', 'quasi'],
|
||||
TemplateElement: [],
|
||||
TemplateLiteral: ['quasis', 'expressions'],
|
||||
ThisExpression: [],
|
||||
ThrowStatement: ['argument'],
|
||||
TryStatement: ['block', 'handler', 'finalizer'],
|
||||
UnaryExpression: ['argument'],
|
||||
UpdateExpression: ['argument'],
|
||||
VariableDeclaration: ['declarations'],
|
||||
VariableDeclarator: ['id', 'init'],
|
||||
WhileStatement: ['test', 'body'],
|
||||
WithStatement: ['object', 'body'],
|
||||
YieldExpression: ['argument']
|
||||
};
|
||||
|
||||
// unique id
|
||||
BREAK = {};
|
||||
SKIP = {};
|
||||
REMOVE = {};
|
||||
|
||||
VisitorOption = {
|
||||
Break: BREAK,
|
||||
Skip: SKIP,
|
||||
Remove: REMOVE
|
||||
};
|
||||
|
||||
function Reference(parent, key) {
|
||||
this.parent = parent;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
Reference.prototype.replace = function replace(node) {
|
||||
this.parent[this.key] = node;
|
||||
};
|
||||
|
||||
Reference.prototype.remove = function remove() {
|
||||
if (Array.isArray(this.parent)) {
|
||||
this.parent.splice(this.key, 1);
|
||||
return true;
|
||||
} else {
|
||||
this.replace(null);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function Element(node, path, wrap, ref) {
|
||||
this.node = node;
|
||||
this.path = path;
|
||||
this.wrap = wrap;
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
function Controller() { }
|
||||
|
||||
// API:
|
||||
// return property path array from root to current node
|
||||
Controller.prototype.path = function path() {
|
||||
var i, iz, j, jz, result, element;
|
||||
|
||||
function addToPath(result, path) {
|
||||
if (Array.isArray(path)) {
|
||||
for (j = 0, jz = path.length; j < jz; ++j) {
|
||||
result.push(path[j]);
|
||||
}
|
||||
} else {
|
||||
result.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
// root node
|
||||
if (!this.__current.path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// first node is sentinel, second node is root element
|
||||
result = [];
|
||||
for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
|
||||
element = this.__leavelist[i];
|
||||
addToPath(result, element.path);
|
||||
}
|
||||
addToPath(result, this.__current.path);
|
||||
return result;
|
||||
};
|
||||
|
||||
// API:
|
||||
// return type of current node
|
||||
Controller.prototype.type = function () {
|
||||
var node = this.current();
|
||||
return node.type || this.__current.wrap;
|
||||
};
|
||||
|
||||
// API:
|
||||
// return array of parent elements
|
||||
Controller.prototype.parents = function parents() {
|
||||
var i, iz, result;
|
||||
|
||||
// first node is sentinel
|
||||
result = [];
|
||||
for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
|
||||
result.push(this.__leavelist[i].node);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// API:
|
||||
// return current node
|
||||
Controller.prototype.current = function current() {
|
||||
return this.__current.node;
|
||||
};
|
||||
|
||||
Controller.prototype.__execute = function __execute(callback, element) {
|
||||
var previous, result;
|
||||
|
||||
result = undefined;
|
||||
|
||||
previous = this.__current;
|
||||
this.__current = element;
|
||||
this.__state = null;
|
||||
if (callback) {
|
||||
result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
|
||||
}
|
||||
this.__current = previous;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// API:
|
||||
// notify control skip / break
|
||||
Controller.prototype.notify = function notify(flag) {
|
||||
this.__state = flag;
|
||||
};
|
||||
|
||||
// API:
|
||||
// skip child nodes of current node
|
||||
Controller.prototype.skip = function () {
|
||||
this.notify(SKIP);
|
||||
};
|
||||
|
||||
// API:
|
||||
// break traversals
|
||||
Controller.prototype['break'] = function () {
|
||||
this.notify(BREAK);
|
||||
};
|
||||
|
||||
// API:
|
||||
// remove node
|
||||
Controller.prototype.remove = function () {
|
||||
this.notify(REMOVE);
|
||||
};
|
||||
|
||||
Controller.prototype.__initialize = function(root, visitor) {
|
||||
this.visitor = visitor;
|
||||
this.root = root;
|
||||
this.__worklist = [];
|
||||
this.__leavelist = [];
|
||||
this.__current = null;
|
||||
this.__state = null;
|
||||
this.__fallback = null;
|
||||
if (visitor.fallback === 'iteration') {
|
||||
this.__fallback = Object.keys;
|
||||
} else if (typeof visitor.fallback === 'function') {
|
||||
this.__fallback = visitor.fallback;
|
||||
}
|
||||
|
||||
this.__keys = VisitorKeys;
|
||||
if (visitor.keys) {
|
||||
this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
|
||||
}
|
||||
};
|
||||
|
||||
function isNode(node) {
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
return typeof node === 'object' && typeof node.type === 'string';
|
||||
}
|
||||
|
||||
function isProperty(nodeType, key) {
|
||||
return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
|
||||
}
|
||||
|
||||
Controller.prototype.traverse = function traverse(root, visitor) {
|
||||
var worklist,
|
||||
leavelist,
|
||||
element,
|
||||
node,
|
||||
nodeType,
|
||||
ret,
|
||||
key,
|
||||
current,
|
||||
current2,
|
||||
candidates,
|
||||
candidate,
|
||||
sentinel;
|
||||
|
||||
this.__initialize(root, visitor);
|
||||
|
||||
sentinel = {};
|
||||
|
||||
// reference
|
||||
worklist = this.__worklist;
|
||||
leavelist = this.__leavelist;
|
||||
|
||||
// initialize
|
||||
worklist.push(new Element(root, null, null, null));
|
||||
leavelist.push(new Element(null, null, null, null));
|
||||
|
||||
while (worklist.length) {
|
||||
element = worklist.pop();
|
||||
|
||||
if (element === sentinel) {
|
||||
element = leavelist.pop();
|
||||
|
||||
ret = this.__execute(visitor.leave, element);
|
||||
|
||||
if (this.__state === BREAK || ret === BREAK) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (element.node) {
|
||||
|
||||
ret = this.__execute(visitor.enter, element);
|
||||
|
||||
if (this.__state === BREAK || ret === BREAK) {
|
||||
return;
|
||||
}
|
||||
|
||||
worklist.push(sentinel);
|
||||
leavelist.push(element);
|
||||
|
||||
if (this.__state === SKIP || ret === SKIP) {
|
||||
continue;
|
||||
}
|
||||
|
||||
node = element.node;
|
||||
nodeType = node.type || element.wrap;
|
||||
candidates = this.__keys[nodeType];
|
||||
if (!candidates) {
|
||||
if (this.__fallback) {
|
||||
candidates = this.__fallback(node);
|
||||
} else {
|
||||
throw new Error('Unknown node type ' + nodeType + '.');
|
||||
}
|
||||
}
|
||||
|
||||
current = candidates.length;
|
||||
while ((current -= 1) >= 0) {
|
||||
key = candidates[current];
|
||||
candidate = node[key];
|
||||
if (!candidate) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(candidate)) {
|
||||
current2 = candidate.length;
|
||||
while ((current2 -= 1) >= 0) {
|
||||
if (!candidate[current2]) {
|
||||
continue;
|
||||
}
|
||||
if (isProperty(nodeType, candidates[current])) {
|
||||
element = new Element(candidate[current2], [key, current2], 'Property', null);
|
||||
} else if (isNode(candidate[current2])) {
|
||||
element = new Element(candidate[current2], [key, current2], null, null);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
worklist.push(element);
|
||||
}
|
||||
} else if (isNode(candidate)) {
|
||||
worklist.push(new Element(candidate, key, null, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Controller.prototype.replace = function replace(root, visitor) {
|
||||
var worklist,
|
||||
leavelist,
|
||||
node,
|
||||
nodeType,
|
||||
target,
|
||||
element,
|
||||
current,
|
||||
current2,
|
||||
candidates,
|
||||
candidate,
|
||||
sentinel,
|
||||
outer,
|
||||
key;
|
||||
|
||||
function removeElem(element) {
|
||||
var i,
|
||||
key,
|
||||
nextElem,
|
||||
parent;
|
||||
|
||||
if (element.ref.remove()) {
|
||||
// When the reference is an element of an array.
|
||||
key = element.ref.key;
|
||||
parent = element.ref.parent;
|
||||
|
||||
// If removed from array, then decrease following items' keys.
|
||||
i = worklist.length;
|
||||
while (i--) {
|
||||
nextElem = worklist[i];
|
||||
if (nextElem.ref && nextElem.ref.parent === parent) {
|
||||
if (nextElem.ref.key < key) {
|
||||
break;
|
||||
}
|
||||
--nextElem.ref.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.__initialize(root, visitor);
|
||||
|
||||
sentinel = {};
|
||||
|
||||
// reference
|
||||
worklist = this.__worklist;
|
||||
leavelist = this.__leavelist;
|
||||
|
||||
// initialize
|
||||
outer = {
|
||||
root: root
|
||||
};
|
||||
element = new Element(root, null, null, new Reference(outer, 'root'));
|
||||
worklist.push(element);
|
||||
leavelist.push(element);
|
||||
|
||||
while (worklist.length) {
|
||||
element = worklist.pop();
|
||||
|
||||
if (element === sentinel) {
|
||||
element = leavelist.pop();
|
||||
|
||||
target = this.__execute(visitor.leave, element);
|
||||
|
||||
// node may be replaced with null,
|
||||
// so distinguish between undefined and null in this place
|
||||
if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
|
||||
// replace
|
||||
element.ref.replace(target);
|
||||
}
|
||||
|
||||
if (this.__state === REMOVE || target === REMOVE) {
|
||||
removeElem(element);
|
||||
}
|
||||
|
||||
if (this.__state === BREAK || target === BREAK) {
|
||||
return outer.root;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
target = this.__execute(visitor.enter, element);
|
||||
|
||||
// node may be replaced with null,
|
||||
// so distinguish between undefined and null in this place
|
||||
if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
|
||||
// replace
|
||||
element.ref.replace(target);
|
||||
element.node = target;
|
||||
}
|
||||
|
||||
if (this.__state === REMOVE || target === REMOVE) {
|
||||
removeElem(element);
|
||||
element.node = null;
|
||||
}
|
||||
|
||||
if (this.__state === BREAK || target === BREAK) {
|
||||
return outer.root;
|
||||
}
|
||||
|
||||
// node may be null
|
||||
node = element.node;
|
||||
if (!node) {
|
||||
continue;
|
||||
}
|
||||
|
||||
worklist.push(sentinel);
|
||||
leavelist.push(element);
|
||||
|
||||
if (this.__state === SKIP || target === SKIP) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nodeType = node.type || element.wrap;
|
||||
candidates = this.__keys[nodeType];
|
||||
if (!candidates) {
|
||||
if (this.__fallback) {
|
||||
candidates = this.__fallback(node);
|
||||
} else {
|
||||
throw new Error('Unknown node type ' + nodeType + '.');
|
||||
}
|
||||
}
|
||||
|
||||
current = candidates.length;
|
||||
while ((current -= 1) >= 0) {
|
||||
key = candidates[current];
|
||||
candidate = node[key];
|
||||
if (!candidate) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(candidate)) {
|
||||
current2 = candidate.length;
|
||||
while ((current2 -= 1) >= 0) {
|
||||
if (!candidate[current2]) {
|
||||
continue;
|
||||
}
|
||||
if (isProperty(nodeType, candidates[current])) {
|
||||
element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
|
||||
} else if (isNode(candidate[current2])) {
|
||||
element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
worklist.push(element);
|
||||
}
|
||||
} else if (isNode(candidate)) {
|
||||
worklist.push(new Element(candidate, key, null, new Reference(node, key)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return outer.root;
|
||||
};
|
||||
|
||||
function traverse(root, visitor) {
|
||||
var controller = new Controller();
|
||||
return controller.traverse(root, visitor);
|
||||
}
|
||||
|
||||
function replace(root, visitor) {
|
||||
var controller = new Controller();
|
||||
return controller.replace(root, visitor);
|
||||
}
|
||||
|
||||
function extendCommentRange(comment, tokens) {
|
||||
var target;
|
||||
|
||||
target = upperBound(tokens, function search(token) {
|
||||
return token.range[0] > comment.range[0];
|
||||
});
|
||||
|
||||
comment.extendedRange = [comment.range[0], comment.range[1]];
|
||||
|
||||
if (target !== tokens.length) {
|
||||
comment.extendedRange[1] = tokens[target].range[0];
|
||||
}
|
||||
|
||||
target -= 1;
|
||||
if (target >= 0) {
|
||||
comment.extendedRange[0] = tokens[target].range[1];
|
||||
}
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
function attachComments(tree, providedComments, tokens) {
|
||||
// At first, we should calculate extended comment ranges.
|
||||
var comments = [], comment, len, i, cursor;
|
||||
|
||||
if (!tree.range) {
|
||||
throw new Error('attachComments needs range information');
|
||||
}
|
||||
|
||||
// tokens array is empty, we attach comments to tree as 'leadingComments'
|
||||
if (!tokens.length) {
|
||||
if (providedComments.length) {
|
||||
for (i = 0, len = providedComments.length; i < len; i += 1) {
|
||||
comment = deepCopy(providedComments[i]);
|
||||
comment.extendedRange = [0, tree.range[0]];
|
||||
comments.push(comment);
|
||||
}
|
||||
tree.leadingComments = comments;
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
for (i = 0, len = providedComments.length; i < len; i += 1) {
|
||||
comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
|
||||
}
|
||||
|
||||
// This is based on John Freeman's implementation.
|
||||
cursor = 0;
|
||||
traverse(tree, {
|
||||
enter: function (node) {
|
||||
var comment;
|
||||
|
||||
while (cursor < comments.length) {
|
||||
comment = comments[cursor];
|
||||
if (comment.extendedRange[1] > node.range[0]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (comment.extendedRange[1] === node.range[0]) {
|
||||
if (!node.leadingComments) {
|
||||
node.leadingComments = [];
|
||||
}
|
||||
node.leadingComments.push(comment);
|
||||
comments.splice(cursor, 1);
|
||||
} else {
|
||||
cursor += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// already out of owned node
|
||||
if (cursor === comments.length) {
|
||||
return VisitorOption.Break;
|
||||
}
|
||||
|
||||
if (comments[cursor].extendedRange[0] > node.range[1]) {
|
||||
return VisitorOption.Skip;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cursor = 0;
|
||||
traverse(tree, {
|
||||
leave: function (node) {
|
||||
var comment;
|
||||
|
||||
while (cursor < comments.length) {
|
||||
comment = comments[cursor];
|
||||
if (node.range[1] < comment.extendedRange[0]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (node.range[1] === comment.extendedRange[0]) {
|
||||
if (!node.trailingComments) {
|
||||
node.trailingComments = [];
|
||||
}
|
||||
node.trailingComments.push(comment);
|
||||
comments.splice(cursor, 1);
|
||||
} else {
|
||||
cursor += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// already out of owned node
|
||||
if (cursor === comments.length) {
|
||||
return VisitorOption.Break;
|
||||
}
|
||||
|
||||
if (comments[cursor].extendedRange[0] > node.range[1]) {
|
||||
return VisitorOption.Skip;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
exports.version = require('./package.json').version;
|
||||
exports.Syntax = Syntax;
|
||||
exports.traverse = traverse;
|
||||
exports.replace = replace;
|
||||
exports.attachComments = attachComments;
|
||||
exports.VisitorKeys = VisitorKeys;
|
||||
exports.VisitorOption = VisitorOption;
|
||||
exports.Controller = Controller;
|
||||
exports.cloneEnvironment = function () { return clone({}); };
|
||||
|
||||
return exports;
|
||||
}(exports));
|
||||
/* vim: set sw=4 ts=4 et tw=80 : */
|
70
node_modules/estraverse/gulpfile.js
generated
vendored
Normal file
70
node_modules/estraverse/gulpfile.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var gulp = require('gulp'),
|
||||
git = require('gulp-git'),
|
||||
bump = require('gulp-bump'),
|
||||
filter = require('gulp-filter'),
|
||||
tagVersion = require('gulp-tag-version');
|
||||
|
||||
var TEST = [ 'test/*.js' ];
|
||||
var POWERED = [ 'powered-test/*.js' ];
|
||||
var SOURCE = [ 'src/**/*.js' ];
|
||||
|
||||
/**
|
||||
* Bumping version number and tagging the repository with it.
|
||||
* Please read http://semver.org/
|
||||
*
|
||||
* You can use the commands
|
||||
*
|
||||
* gulp patch # makes v0.1.0 -> v0.1.1
|
||||
* gulp feature # makes v0.1.1 -> v0.2.0
|
||||
* gulp release # makes v0.2.1 -> v1.0.0
|
||||
*
|
||||
* To bump the version numbers accordingly after you did a patch,
|
||||
* introduced a feature or made a backwards-incompatible release.
|
||||
*/
|
||||
|
||||
function inc(importance) {
|
||||
// get all the files to bump version in
|
||||
return gulp.src(['./package.json'])
|
||||
// bump the version number in those files
|
||||
.pipe(bump({type: importance}))
|
||||
// save it back to filesystem
|
||||
.pipe(gulp.dest('./'))
|
||||
// commit the changed version number
|
||||
.pipe(git.commit('Bumps package version'))
|
||||
// read only one file to get the version number
|
||||
.pipe(filter('package.json'))
|
||||
// **tag it in the repository**
|
||||
.pipe(tagVersion({
|
||||
prefix: ''
|
||||
}));
|
||||
}
|
||||
|
||||
gulp.task('patch', [ ], function () { return inc('patch'); })
|
||||
gulp.task('minor', [ ], function () { return inc('minor'); })
|
||||
gulp.task('major', [ ], function () { return inc('major'); })
|
68
node_modules/estraverse/package.json
generated
vendored
Normal file
68
node_modules/estraverse/package.json
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"_from": "estraverse@^4.2.0",
|
||||
"_id": "estraverse@4.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
|
||||
"_location": "/estraverse",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "estraverse@^4.2.0",
|
||||
"name": "estraverse",
|
||||
"escapedName": "estraverse",
|
||||
"rawSpec": "^4.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/escodegen"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
|
||||
"_shasum": "398ad3f3c5a24948be7725e83d11a7de28cdbd1d",
|
||||
"_spec": "estraverse@^4.2.0",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules\\escodegen",
|
||||
"bugs": {
|
||||
"url": "https://github.com/estools/estraverse/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "ECMAScript JS AST traversal functions",
|
||||
"devDependencies": {
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-register": "^6.3.13",
|
||||
"chai": "^2.1.1",
|
||||
"espree": "^1.11.0",
|
||||
"gulp": "^3.8.10",
|
||||
"gulp-bump": "^0.2.2",
|
||||
"gulp-filter": "^2.0.0",
|
||||
"gulp-git": "^1.0.1",
|
||||
"gulp-tag-version": "^1.3.0",
|
||||
"jshint": "^2.5.6",
|
||||
"mocha": "^2.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"homepage": "https://github.com/estools/estraverse",
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "estraverse.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Yusuke Suzuki",
|
||||
"email": "utatane.tea@gmail.com",
|
||||
"url": "http://github.com/Constellation"
|
||||
}
|
||||
],
|
||||
"name": "estraverse",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/estools/estraverse.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "jshint estraverse.js",
|
||||
"test": "npm run-script lint && npm run-script unit-test",
|
||||
"unit-test": "mocha --compilers js:babel-register"
|
||||
},
|
||||
"version": "4.3.0"
|
||||
}
|
19
node_modules/esutils/LICENSE.BSD
generated
vendored
Normal file
19
node_modules/esutils/LICENSE.BSD
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
174
node_modules/esutils/README.md
generated
vendored
Normal file
174
node_modules/esutils/README.md
generated
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
### esutils [](http://travis-ci.org/estools/esutils)
|
||||
esutils ([esutils](http://github.com/estools/esutils)) is
|
||||
utility box for ECMAScript language tools.
|
||||
|
||||
### API
|
||||
|
||||
### ast
|
||||
|
||||
#### ast.isExpression(node)
|
||||
|
||||
Returns true if `node` is an Expression as defined in ECMA262 edition 5.1 section
|
||||
[11](https://es5.github.io/#x11).
|
||||
|
||||
#### ast.isStatement(node)
|
||||
|
||||
Returns true if `node` is a Statement as defined in ECMA262 edition 5.1 section
|
||||
[12](https://es5.github.io/#x12).
|
||||
|
||||
#### ast.isIterationStatement(node)
|
||||
|
||||
Returns true if `node` is an IterationStatement as defined in ECMA262 edition
|
||||
5.1 section [12.6](https://es5.github.io/#x12.6).
|
||||
|
||||
#### ast.isSourceElement(node)
|
||||
|
||||
Returns true if `node` is a SourceElement as defined in ECMA262 edition 5.1
|
||||
section [14](https://es5.github.io/#x14).
|
||||
|
||||
#### ast.trailingStatement(node)
|
||||
|
||||
Returns `Statement?` if `node` has trailing `Statement`.
|
||||
```js
|
||||
if (cond)
|
||||
consequent;
|
||||
```
|
||||
When taking this `IfStatement`, returns `consequent;` statement.
|
||||
|
||||
#### ast.isProblematicIfStatement(node)
|
||||
|
||||
Returns true if `node` is a problematic IfStatement. If `node` is a problematic `IfStatement`, `node` cannot be represented as an one on one JavaScript code.
|
||||
```js
|
||||
{
|
||||
type: 'IfStatement',
|
||||
consequent: {
|
||||
type: 'WithStatement',
|
||||
body: {
|
||||
type: 'IfStatement',
|
||||
consequent: {type: 'EmptyStatement'}
|
||||
}
|
||||
},
|
||||
alternate: {type: 'EmptyStatement'}
|
||||
}
|
||||
```
|
||||
The above node cannot be represented as a JavaScript code, since the top level `else` alternate belongs to an inner `IfStatement`.
|
||||
|
||||
|
||||
### code
|
||||
|
||||
#### code.isDecimalDigit(code)
|
||||
|
||||
Return true if provided code is decimal digit.
|
||||
|
||||
#### code.isHexDigit(code)
|
||||
|
||||
Return true if provided code is hexadecimal digit.
|
||||
|
||||
#### code.isOctalDigit(code)
|
||||
|
||||
Return true if provided code is octal digit.
|
||||
|
||||
#### code.isWhiteSpace(code)
|
||||
|
||||
Return true if provided code is white space. White space characters are formally defined in ECMA262.
|
||||
|
||||
#### code.isLineTerminator(code)
|
||||
|
||||
Return true if provided code is line terminator. Line terminator characters are formally defined in ECMA262.
|
||||
|
||||
#### code.isIdentifierStart(code)
|
||||
|
||||
Return true if provided code can be the first character of ECMA262 Identifier. They are formally defined in ECMA262.
|
||||
|
||||
#### code.isIdentifierPart(code)
|
||||
|
||||
Return true if provided code can be the trailing character of ECMA262 Identifier. They are formally defined in ECMA262.
|
||||
|
||||
### keyword
|
||||
|
||||
#### keyword.isKeywordES5(id, strict)
|
||||
|
||||
Returns `true` if provided identifier string is a Keyword or Future Reserved Word
|
||||
in ECMA262 edition 5.1. They are formally defined in ECMA262 sections
|
||||
[7.6.1.1](http://es5.github.io/#x7.6.1.1) and [7.6.1.2](http://es5.github.io/#x7.6.1.2),
|
||||
respectively. If the `strict` flag is truthy, this function additionally checks whether
|
||||
`id` is a Keyword or Future Reserved Word under strict mode.
|
||||
|
||||
#### keyword.isKeywordES6(id, strict)
|
||||
|
||||
Returns `true` if provided identifier string is a Keyword or Future Reserved Word
|
||||
in ECMA262 edition 6. They are formally defined in ECMA262 sections
|
||||
[11.6.2.1](http://ecma-international.org/ecma-262/6.0/#sec-keywords) and
|
||||
[11.6.2.2](http://ecma-international.org/ecma-262/6.0/#sec-future-reserved-words),
|
||||
respectively. If the `strict` flag is truthy, this function additionally checks whether
|
||||
`id` is a Keyword or Future Reserved Word under strict mode.
|
||||
|
||||
#### keyword.isReservedWordES5(id, strict)
|
||||
|
||||
Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 5.1.
|
||||
They are formally defined in ECMA262 section [7.6.1](http://es5.github.io/#x7.6.1).
|
||||
If the `strict` flag is truthy, this function additionally checks whether `id`
|
||||
is a Reserved Word under strict mode.
|
||||
|
||||
#### keyword.isReservedWordES6(id, strict)
|
||||
|
||||
Returns `true` if provided identifier string is a Reserved Word in ECMA262 edition 6.
|
||||
They are formally defined in ECMA262 section [11.6.2](http://ecma-international.org/ecma-262/6.0/#sec-reserved-words).
|
||||
If the `strict` flag is truthy, this function additionally checks whether `id`
|
||||
is a Reserved Word under strict mode.
|
||||
|
||||
#### keyword.isRestrictedWord(id)
|
||||
|
||||
Returns `true` if provided identifier string is one of `eval` or `arguments`.
|
||||
They are restricted in strict mode code throughout ECMA262 edition 5.1 and
|
||||
in ECMA262 edition 6 section [12.1.1](http://ecma-international.org/ecma-262/6.0/#sec-identifiers-static-semantics-early-errors).
|
||||
|
||||
#### keyword.isIdentifierNameES5(id)
|
||||
|
||||
Return true if provided identifier string is an IdentifierName as specified in
|
||||
ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6).
|
||||
|
||||
#### keyword.isIdentifierNameES6(id)
|
||||
|
||||
Return true if provided identifier string is an IdentifierName as specified in
|
||||
ECMA262 edition 6 section [11.6](http://ecma-international.org/ecma-262/6.0/#sec-names-and-keywords).
|
||||
|
||||
#### keyword.isIdentifierES5(id, strict)
|
||||
|
||||
Return true if provided identifier string is an Identifier as specified in
|
||||
ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6). If the `strict`
|
||||
flag is truthy, this function additionally checks whether `id` is an Identifier
|
||||
under strict mode.
|
||||
|
||||
#### keyword.isIdentifierES6(id, strict)
|
||||
|
||||
Return true if provided identifier string is an Identifier as specified in
|
||||
ECMA262 edition 6 section [12.1](http://ecma-international.org/ecma-262/6.0/#sec-identifiers).
|
||||
If the `strict` flag is truthy, this function additionally checks whether `id`
|
||||
is an Identifier under strict mode.
|
||||
|
||||
### License
|
||||
|
||||
Copyright (C) 2013 [Yusuke Suzuki](http://github.com/Constellation)
|
||||
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
144
node_modules/esutils/lib/ast.js
generated
vendored
Normal file
144
node_modules/esutils/lib/ast.js
generated
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function isExpression(node) {
|
||||
if (node == null) { return false; }
|
||||
switch (node.type) {
|
||||
case 'ArrayExpression':
|
||||
case 'AssignmentExpression':
|
||||
case 'BinaryExpression':
|
||||
case 'CallExpression':
|
||||
case 'ConditionalExpression':
|
||||
case 'FunctionExpression':
|
||||
case 'Identifier':
|
||||
case 'Literal':
|
||||
case 'LogicalExpression':
|
||||
case 'MemberExpression':
|
||||
case 'NewExpression':
|
||||
case 'ObjectExpression':
|
||||
case 'SequenceExpression':
|
||||
case 'ThisExpression':
|
||||
case 'UnaryExpression':
|
||||
case 'UpdateExpression':
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isIterationStatement(node) {
|
||||
if (node == null) { return false; }
|
||||
switch (node.type) {
|
||||
case 'DoWhileStatement':
|
||||
case 'ForInStatement':
|
||||
case 'ForStatement':
|
||||
case 'WhileStatement':
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isStatement(node) {
|
||||
if (node == null) { return false; }
|
||||
switch (node.type) {
|
||||
case 'BlockStatement':
|
||||
case 'BreakStatement':
|
||||
case 'ContinueStatement':
|
||||
case 'DebuggerStatement':
|
||||
case 'DoWhileStatement':
|
||||
case 'EmptyStatement':
|
||||
case 'ExpressionStatement':
|
||||
case 'ForInStatement':
|
||||
case 'ForStatement':
|
||||
case 'IfStatement':
|
||||
case 'LabeledStatement':
|
||||
case 'ReturnStatement':
|
||||
case 'SwitchStatement':
|
||||
case 'ThrowStatement':
|
||||
case 'TryStatement':
|
||||
case 'VariableDeclaration':
|
||||
case 'WhileStatement':
|
||||
case 'WithStatement':
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isSourceElement(node) {
|
||||
return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
|
||||
}
|
||||
|
||||
function trailingStatement(node) {
|
||||
switch (node.type) {
|
||||
case 'IfStatement':
|
||||
if (node.alternate != null) {
|
||||
return node.alternate;
|
||||
}
|
||||
return node.consequent;
|
||||
|
||||
case 'LabeledStatement':
|
||||
case 'ForStatement':
|
||||
case 'ForInStatement':
|
||||
case 'WhileStatement':
|
||||
case 'WithStatement':
|
||||
return node.body;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function isProblematicIfStatement(node) {
|
||||
var current;
|
||||
|
||||
if (node.type !== 'IfStatement') {
|
||||
return false;
|
||||
}
|
||||
if (node.alternate == null) {
|
||||
return false;
|
||||
}
|
||||
current = node.consequent;
|
||||
do {
|
||||
if (current.type === 'IfStatement') {
|
||||
if (current.alternate == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
current = trailingStatement(current);
|
||||
} while (current);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isExpression: isExpression,
|
||||
isStatement: isStatement,
|
||||
isIterationStatement: isIterationStatement,
|
||||
isSourceElement: isSourceElement,
|
||||
isProblematicIfStatement: isProblematicIfStatement,
|
||||
|
||||
trailingStatement: trailingStatement
|
||||
};
|
||||
}());
|
||||
/* vim: set sw=4 ts=4 et tw=80 : */
|
135
node_modules/esutils/lib/code.js
generated
vendored
Normal file
135
node_modules/esutils/lib/code.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
165
node_modules/esutils/lib/keyword.js
generated
vendored
Normal file
165
node_modules/esutils/lib/keyword.js
generated
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var code = require('./code');
|
||||
|
||||
function isStrictModeReservedWordES6(id) {
|
||||
switch (id) {
|
||||
case 'implements':
|
||||
case 'interface':
|
||||
case 'package':
|
||||
case 'private':
|
||||
case 'protected':
|
||||
case 'public':
|
||||
case 'static':
|
||||
case 'let':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isKeywordES5(id, strict) {
|
||||
// yield should not be treated as keyword under non-strict mode.
|
||||
if (!strict && id === 'yield') {
|
||||
return false;
|
||||
}
|
||||
return isKeywordES6(id, strict);
|
||||
}
|
||||
|
||||
function isKeywordES6(id, strict) {
|
||||
if (strict && isStrictModeReservedWordES6(id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (id.length) {
|
||||
case 2:
|
||||
return (id === 'if') || (id === 'in') || (id === 'do');
|
||||
case 3:
|
||||
return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try');
|
||||
case 4:
|
||||
return (id === 'this') || (id === 'else') || (id === 'case') ||
|
||||
(id === 'void') || (id === 'with') || (id === 'enum');
|
||||
case 5:
|
||||
return (id === 'while') || (id === 'break') || (id === 'catch') ||
|
||||
(id === 'throw') || (id === 'const') || (id === 'yield') ||
|
||||
(id === 'class') || (id === 'super');
|
||||
case 6:
|
||||
return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
|
||||
(id === 'switch') || (id === 'export') || (id === 'import');
|
||||
case 7:
|
||||
return (id === 'default') || (id === 'finally') || (id === 'extends');
|
||||
case 8:
|
||||
return (id === 'function') || (id === 'continue') || (id === 'debugger');
|
||||
case 10:
|
||||
return (id === 'instanceof');
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isReservedWordES5(id, strict) {
|
||||
return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
|
||||
}
|
||||
|
||||
function isReservedWordES6(id, strict) {
|
||||
return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
|
||||
}
|
||||
|
||||
function isRestrictedWord(id) {
|
||||
return id === 'eval' || id === 'arguments';
|
||||
}
|
||||
|
||||
function isIdentifierNameES5(id) {
|
||||
var i, iz, ch;
|
||||
|
||||
if (id.length === 0) { return false; }
|
||||
|
||||
ch = id.charCodeAt(0);
|
||||
if (!code.isIdentifierStartES5(ch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 1, iz = id.length; i < iz; ++i) {
|
||||
ch = id.charCodeAt(i);
|
||||
if (!code.isIdentifierPartES5(ch)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function decodeUtf16(lead, trail) {
|
||||
return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
|
||||
}
|
||||
|
||||
function isIdentifierNameES6(id) {
|
||||
var i, iz, ch, lowCh, check;
|
||||
|
||||
if (id.length === 0) { return false; }
|
||||
|
||||
check = code.isIdentifierStartES6;
|
||||
for (i = 0, iz = id.length; i < iz; ++i) {
|
||||
ch = id.charCodeAt(i);
|
||||
if (0xD800 <= ch && ch <= 0xDBFF) {
|
||||
++i;
|
||||
if (i >= iz) { return false; }
|
||||
lowCh = id.charCodeAt(i);
|
||||
if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
|
||||
return false;
|
||||
}
|
||||
ch = decodeUtf16(ch, lowCh);
|
||||
}
|
||||
if (!check(ch)) {
|
||||
return false;
|
||||
}
|
||||
check = code.isIdentifierPartES6;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isIdentifierES5(id, strict) {
|
||||
return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
|
||||
}
|
||||
|
||||
function isIdentifierES6(id, strict) {
|
||||
return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isKeywordES5: isKeywordES5,
|
||||
isKeywordES6: isKeywordES6,
|
||||
isReservedWordES5: isReservedWordES5,
|
||||
isReservedWordES6: isReservedWordES6,
|
||||
isRestrictedWord: isRestrictedWord,
|
||||
isIdentifierNameES5: isIdentifierNameES5,
|
||||
isIdentifierNameES6: isIdentifierNameES6,
|
||||
isIdentifierES5: isIdentifierES5,
|
||||
isIdentifierES6: isIdentifierES6
|
||||
};
|
||||
}());
|
||||
/* vim: set sw=4 ts=4 et tw=80 : */
|
33
node_modules/esutils/lib/utils.js
generated
vendored
Normal file
33
node_modules/esutils/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
exports.ast = require('./ast');
|
||||
exports.code = require('./code');
|
||||
exports.keyword = require('./keyword');
|
||||
}());
|
||||
/* vim: set sw=4 ts=4 et tw=80 : */
|
72
node_modules/esutils/package.json
generated
vendored
Normal file
72
node_modules/esutils/package.json
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
{
|
||||
"_from": "esutils@^2.0.2",
|
||||
"_id": "esutils@2.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"_location": "/esutils",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "esutils@^2.0.2",
|
||||
"name": "esutils",
|
||||
"escapedName": "esutils",
|
||||
"rawSpec": "^2.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/escodegen"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
"_shasum": "74d2eb4de0b8da1293711910d50775b9b710ef64",
|
||||
"_spec": "esutils@^2.0.2",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules\\escodegen",
|
||||
"bugs": {
|
||||
"url": "https://github.com/estools/esutils/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "utility box for ECMAScript language tools",
|
||||
"devDependencies": {
|
||||
"chai": "~1.7.2",
|
||||
"coffee-script": "~1.6.3",
|
||||
"jshint": "2.6.3",
|
||||
"mocha": "~2.2.1",
|
||||
"regenerate": "~1.3.1",
|
||||
"unicode-9.0.0": "~0.7.0"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE.BSD",
|
||||
"README.md",
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/estools/esutils",
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "lib/utils.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Yusuke Suzuki",
|
||||
"email": "utatane.tea@gmail.com",
|
||||
"url": "http://github.com/Constellation"
|
||||
}
|
||||
],
|
||||
"name": "esutils",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/estools/esutils.git"
|
||||
},
|
||||
"scripts": {
|
||||
"generate-regex": "node tools/generate-identifier-regex.js",
|
||||
"lint": "jshint lib/*.js",
|
||||
"test": "npm run-script lint && npm run-script unit-test",
|
||||
"unit-test": "mocha --compilers coffee:coffee-script -R spec"
|
||||
},
|
||||
"version": "2.0.3"
|
||||
}
|
25
node_modules/fast-levenshtein/LICENSE.md
generated
vendored
Normal file
25
node_modules/fast-levenshtein/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
(MIT License)
|
||||
|
||||
Copyright (c) 2013 [Ramesh Nair](http://www.hiddentao.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.
|
||||
|
104
node_modules/fast-levenshtein/README.md
generated
vendored
Normal file
104
node_modules/fast-levenshtein/README.md
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
# fast-levenshtein - Levenshtein algorithm in Javascript
|
||||
|
||||
[](http://travis-ci.org/hiddentao/fast-levenshtein)
|
||||
[](https://badge.fury.io/js/fast-levenshtein)
|
||||
[](https://www.npmjs.com/package/fast-levenshtein)
|
||||
[](https://twitter.com/hiddentao)
|
||||
|
||||
An efficient Javascript implementation of the [Levenshtein algorithm](http://en.wikipedia.org/wiki/Levenshtein_distance) with locale-specific collator support.
|
||||
|
||||
## Features
|
||||
|
||||
* Works in node.js and in the browser.
|
||||
* Better performance than other implementations by not needing to store the whole matrix ([more info](http://www.codeproject.com/Articles/13525/Fast-memory-efficient-Levenshtein-algorithm)).
|
||||
* Locale-sensitive string comparisions if needed.
|
||||
* Comprehensive test suite and performance benchmark.
|
||||
* Small: <1 KB minified and gzipped
|
||||
|
||||
## Installation
|
||||
|
||||
### node.js
|
||||
|
||||
Install using [npm](http://npmjs.org/):
|
||||
|
||||
```bash
|
||||
$ npm install fast-levenshtein
|
||||
```
|
||||
|
||||
### Browser
|
||||
|
||||
Using bower:
|
||||
|
||||
```bash
|
||||
$ bower install fast-levenshtein
|
||||
```
|
||||
|
||||
If you are not using any module loader system then the API will then be accessible via the `window.Levenshtein` object.
|
||||
|
||||
## Examples
|
||||
|
||||
**Default usage**
|
||||
|
||||
```javascript
|
||||
var levenshtein = require('fast-levenshtein');
|
||||
|
||||
var distance = levenshtein.get('back', 'book'); // 2
|
||||
var distance = levenshtein.get('我愛你', '我叫你'); // 1
|
||||
```
|
||||
|
||||
**Locale-sensitive string comparisons**
|
||||
|
||||
It supports using [Intl.Collator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator) for locale-sensitive string comparisons:
|
||||
|
||||
```javascript
|
||||
var levenshtein = require('fast-levenshtein');
|
||||
|
||||
levenshtein.get('mikailovitch', 'Mikhaïlovitch', { useCollator: true});
|
||||
// 1
|
||||
```
|
||||
|
||||
## Building and Testing
|
||||
|
||||
To build the code and run the tests:
|
||||
|
||||
```bash
|
||||
$ npm install -g grunt-cli
|
||||
$ npm install
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
_Thanks to [Titus Wormer](https://github.com/wooorm) for [encouraging me](https://github.com/hiddentao/fast-levenshtein/issues/1) to do this._
|
||||
|
||||
Benchmarked against other node.js levenshtein distance modules (on Macbook Air 2012, Core i7, 8GB RAM):
|
||||
|
||||
```bash
|
||||
Running suite Implementation comparison [benchmark/speed.js]...
|
||||
>> levenshtein-edit-distance x 234 ops/sec ±3.02% (73 runs sampled)
|
||||
>> levenshtein-component x 422 ops/sec ±4.38% (83 runs sampled)
|
||||
>> levenshtein-deltas x 283 ops/sec ±3.83% (78 runs sampled)
|
||||
>> natural x 255 ops/sec ±0.76% (88 runs sampled)
|
||||
>> levenshtein x 180 ops/sec ±3.55% (86 runs sampled)
|
||||
>> fast-levenshtein x 1,792 ops/sec ±2.72% (95 runs sampled)
|
||||
Benchmark done.
|
||||
Fastest test is fast-levenshtein at 4.2x faster than levenshtein-component
|
||||
```
|
||||
|
||||
You can run this benchmark yourself by doing:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm run build
|
||||
$ npm run benchmark
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
If you wish to submit a pull request please update and/or create new tests for any changes you make and ensure the grunt build passes.
|
||||
|
||||
See [CONTRIBUTING.md](https://github.com/hiddentao/fast-levenshtein/blob/master/CONTRIBUTING.md) for details.
|
||||
|
||||
## License
|
||||
|
||||
MIT - see [LICENSE.md](https://github.com/hiddentao/fast-levenshtein/blob/master/LICENSE.md)
|
136
node_modules/fast-levenshtein/levenshtein.js
generated
vendored
Normal file
136
node_modules/fast-levenshtein/levenshtein.js
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var collator;
|
||||
try {
|
||||
collator = (typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined") ? Intl.Collator("generic", { sensitivity: "base" }) : null;
|
||||
} catch (err){
|
||||
console.log("Collator could not be initialized and wouldn't be used");
|
||||
}
|
||||
// arrays to re-use
|
||||
var prevRow = [],
|
||||
str2Char = [];
|
||||
|
||||
/**
|
||||
* Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance.
|
||||
*/
|
||||
var Levenshtein = {
|
||||
/**
|
||||
* Calculate levenshtein distance of the two strings.
|
||||
*
|
||||
* @param str1 String the first string.
|
||||
* @param str2 String the second string.
|
||||
* @param [options] Additional options.
|
||||
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
||||
* @return Integer the levenshtein distance (0 and above).
|
||||
*/
|
||||
get: function(str1, str2, options) {
|
||||
var useCollator = (options && collator && options.useCollator);
|
||||
|
||||
var str1Len = str1.length,
|
||||
str2Len = str2.length;
|
||||
|
||||
// base cases
|
||||
if (str1Len === 0) return str2Len;
|
||||
if (str2Len === 0) return str1Len;
|
||||
|
||||
// two rows
|
||||
var curCol, nextCol, i, j, tmp;
|
||||
|
||||
// initialise previous row
|
||||
for (i=0; i<str2Len; ++i) {
|
||||
prevRow[i] = i;
|
||||
str2Char[i] = str2.charCodeAt(i);
|
||||
}
|
||||
prevRow[str2Len] = str2Len;
|
||||
|
||||
var strCmp;
|
||||
if (useCollator) {
|
||||
// calculate current row distance from previous row using collator
|
||||
for (i = 0; i < str1Len; ++i) {
|
||||
nextCol = i + 1;
|
||||
|
||||
for (j = 0; j < str2Len; ++j) {
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j]));
|
||||
|
||||
nextCol = prevRow[j] + (strCmp ? 0 : 1);
|
||||
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
|
||||
// copy current col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = curCol;
|
||||
}
|
||||
|
||||
// copy last col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = nextCol;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// calculate current row distance from previous row without collator
|
||||
for (i = 0; i < str1Len; ++i) {
|
||||
nextCol = i + 1;
|
||||
|
||||
for (j = 0; j < str2Len; ++j) {
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
strCmp = str1.charCodeAt(i) === str2Char[j];
|
||||
|
||||
nextCol = prevRow[j] + (strCmp ? 0 : 1);
|
||||
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
|
||||
// copy current col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = curCol;
|
||||
}
|
||||
|
||||
// copy last col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = nextCol;
|
||||
}
|
||||
}
|
||||
return nextCol;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// amd
|
||||
if (typeof define !== "undefined" && define !== null && define.amd) {
|
||||
define(function() {
|
||||
return Levenshtein;
|
||||
});
|
||||
}
|
||||
// commonjs
|
||||
else if (typeof module !== "undefined" && module !== null && typeof exports !== "undefined" && module.exports === exports) {
|
||||
module.exports = Levenshtein;
|
||||
}
|
||||
// web worker
|
||||
else if (typeof self !== "undefined" && typeof self.postMessage === 'function' && typeof self.importScripts === 'function') {
|
||||
self.Levenshtein = Levenshtein;
|
||||
}
|
||||
// browser main thread
|
||||
else if (typeof window !== "undefined" && window !== null) {
|
||||
window.Levenshtein = Levenshtein;
|
||||
}
|
||||
}());
|
||||
|
72
node_modules/fast-levenshtein/package.json
generated
vendored
Normal file
72
node_modules/fast-levenshtein/package.json
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
{
|
||||
"_from": "fast-levenshtein@~2.0.6",
|
||||
"_id": "fast-levenshtein@2.0.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
|
||||
"_location": "/fast-levenshtein",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "fast-levenshtein@~2.0.6",
|
||||
"name": "fast-levenshtein",
|
||||
"escapedName": "fast-levenshtein",
|
||||
"rawSpec": "~2.0.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~2.0.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/optionator"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
|
||||
"_shasum": "3d8a5c66883a16a30ca8643e851f19baa7797917",
|
||||
"_spec": "fast-levenshtein@~2.0.6",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules\\optionator",
|
||||
"author": {
|
||||
"name": "Ramesh Nair",
|
||||
"email": "ram@hiddentao.com",
|
||||
"url": "http://www.hiddentao.com/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/hiddentao/fast-levenshtein/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Efficient implementation of Levenshtein algorithm with locale-specific collator support.",
|
||||
"devDependencies": {
|
||||
"chai": "~1.5.0",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-benchmark": "~0.2.0",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-contrib-jshint": "~0.4.3",
|
||||
"grunt-contrib-uglify": "~0.2.0",
|
||||
"grunt-mocha-test": "~0.2.2",
|
||||
"grunt-npm-install": "~0.1.0",
|
||||
"load-grunt-tasks": "~0.6.0",
|
||||
"lodash": "^4.0.1",
|
||||
"mocha": "~1.9.0"
|
||||
},
|
||||
"files": [
|
||||
"levenshtein.js"
|
||||
],
|
||||
"homepage": "https://github.com/hiddentao/fast-levenshtein#readme",
|
||||
"keywords": [
|
||||
"levenshtein",
|
||||
"distance",
|
||||
"string"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "levenshtein.js",
|
||||
"name": "fast-levenshtein",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/hiddentao/fast-levenshtein.git"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "grunt benchmark",
|
||||
"build": "grunt build",
|
||||
"prepublish": "npm run build",
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "2.0.6"
|
||||
}
|
60
node_modules/jsonpath/.jscsrc
generated
vendored
Normal file
60
node_modules/jsonpath/.jscsrc
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"disallowSpacesInNamedFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionDeclaration": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowEmptyBlocks": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowQuotedKeysInObjects": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpaceBeforePostfixUnaryOperators": true,
|
||||
"disallowSpaceBeforeBinaryOperators": [
|
||||
","
|
||||
],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowTrailingComma": true,
|
||||
"disallowYodaConditions": true,
|
||||
"disallowKeywords": [ "with" ],
|
||||
"disallowMultipleLineBreaks": true,
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
"requireSpacesInConditionalExpression": true,
|
||||
"disallowMultipleVarDecl": true,
|
||||
"requireBlocksOnNewline": 1,
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"requireSpaceBeforeBinaryOperators": true,
|
||||
"requireSpaceAfterBinaryOperators": true,
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
"requireDotNotation": true,
|
||||
"requireSpacesInForStatement": true,
|
||||
"requireCurlyBraces": [
|
||||
"do"
|
||||
],
|
||||
"requireSpaceAfterKeywords": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"switch",
|
||||
"case",
|
||||
"return",
|
||||
"try",
|
||||
"catch",
|
||||
"typeof"
|
||||
],
|
||||
"safeContextKeyword": "self",
|
||||
"validateLineBreaks": "LF",
|
||||
"validateIndentation": 2
|
||||
}
|
9
node_modules/jsonpath/.jshintrc
generated
vendored
Normal file
9
node_modules/jsonpath/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"node": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"lastsemic": true,
|
||||
"-W058": false, /* don't require parentheses for no-arg constructors */
|
||||
"-W054": false, /* use Function constructor responsibly */
|
||||
"-W033": false /* let jscs deal with semicolons */
|
||||
}
|
3
node_modules/jsonpath/.travis.yml
generated
vendored
Normal file
3
node_modules/jsonpath/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
1
node_modules/jsonpath/Dockerfile
generated
vendored
Normal file
1
node_modules/jsonpath/Dockerfile
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
FROM node:0.11-onbuild
|
83
node_modules/jsonpath/Gruntfile.js
generated
vendored
Normal file
83
node_modules/jsonpath/Gruntfile.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
var Browserify = require('browserify');
|
||||
var bresolve = require('browser-resolve');
|
||||
patchResolve();
|
||||
|
||||
module.exports = function (grunt) {
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
outputFolder: ".",
|
||||
|
||||
browserify: {
|
||||
main: {
|
||||
src: ['index.js'],
|
||||
dest: '<%= outputFolder %>/<%= pkg.name %>.js',
|
||||
options: {
|
||||
browserifyOptions: { standalone: '<%= pkg.name %>' },
|
||||
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n',
|
||||
alias: {
|
||||
"jsonpath": "./index.js"
|
||||
},
|
||||
require: [
|
||||
/**
|
||||
* When running in Node, we require('./aesprim') and that module takes care of monkey-patching esprima
|
||||
* using resolve, path finding, etc...
|
||||
* Anyways, Browserify doesn't support "resolve", so we need to trick the module. We'll actually be
|
||||
* returning a verbatim, non-modified "esprima" when the code runs require('./aesprim').
|
||||
* That is ok because we will modify the "esprima" source code right after the bundle process, via
|
||||
* the postBundleCB callback.
|
||||
*/
|
||||
["esprima", {expose: "./aesprim"}]
|
||||
],
|
||||
ignore: [
|
||||
'file',
|
||||
'system',
|
||||
'source-map',
|
||||
'estraverse',
|
||||
'escodegen',
|
||||
'underscore',
|
||||
'reflect',
|
||||
'JSONSelect',
|
||||
'./lib/aesprim.js'
|
||||
//'assert' //can't remove because of lib/index.js,
|
||||
],
|
||||
postBundleCB: function(err, src, next) {
|
||||
/**
|
||||
* This is ugly, but we need to make "esprima" understand '@' as a valid character.
|
||||
* It's either this or bundle a copy of the library with those few bytes of changes.
|
||||
*/
|
||||
src = src.toString("utf8").replace(/(function isIdentifierStart\(ch\) {\s+return)/m, '$1 (ch == 0x40) || ');
|
||||
next(err, new Buffer(src, "utf8"));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
|
||||
},
|
||||
build: {
|
||||
src: '<%= outputFolder %>/<%= pkg.name %>.js',
|
||||
dest: '<%= outputFolder %>/<%= pkg.name %>.min.js'
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-browserify');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify')
|
||||
grunt.registerTask('default', ['browserify', 'uglify']);
|
||||
|
||||
};
|
||||
|
||||
function patchResolve() {
|
||||
var _createDeps = Browserify.prototype._createDeps;
|
||||
Browserify.prototype._createDeps = function() {
|
||||
var returnValue = _createDeps.apply(this, arguments);
|
||||
this._bresolve = function(id, opts, cb) {
|
||||
opts.browser = 'alias';
|
||||
return bresolve(id, opts, cb);
|
||||
};
|
||||
return returnValue;
|
||||
}
|
||||
}
|
7
node_modules/jsonpath/LICENSE
generated
vendored
Normal file
7
node_modules/jsonpath/LICENSE
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright (c) 2014-2016 David Chester <david@fmail.co.uk>
|
||||
|
||||
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.
|
216
node_modules/jsonpath/README.md
generated
vendored
Normal file
216
node_modules/jsonpath/README.md
generated
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
[](https://travis-ci.org/dchester/jsonpath)
|
||||
|
||||
# jsonpath
|
||||
|
||||
Query JavaScript objects with JSONPath expressions. Robust / safe JSONPath engine for Node.js.
|
||||
|
||||
|
||||
## Query Example
|
||||
|
||||
```javascript
|
||||
var cities = [
|
||||
{ name: "London", "population": 8615246 },
|
||||
{ name: "Berlin", "population": 3517424 },
|
||||
{ name: "Madrid", "population": 3165235 },
|
||||
{ name: "Rome", "population": 2870528 }
|
||||
];
|
||||
|
||||
var jp = require('jsonpath');
|
||||
var names = jp.query(cities, '$..name');
|
||||
|
||||
// [ "London", "Berlin", "Madrid", "Rome" ]
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Install from npm:
|
||||
```bash
|
||||
$ npm install jsonpath
|
||||
```
|
||||
|
||||
## JSONPath Syntax
|
||||
|
||||
Here are syntax and examples adapted from [Stefan Goessner's original post](http://goessner.net/articles/JsonPath/) introducing JSONPath in 2007.
|
||||
|
||||
JSONPath | Description
|
||||
-----------------|------------
|
||||
`$` | The root object/element
|
||||
`@` | The current object/element
|
||||
`.` | Child member operator
|
||||
`..` | Recursive descendant operator; JSONPath borrows this syntax from E4X
|
||||
`*` | Wildcard matching all objects/elements regardless their names
|
||||
`[]` | Subscript operator
|
||||
`[,]` | Union operator for alternate names or array indices as a set
|
||||
`[start:end:step]` | Array slice operator borrowed from ES4 / Python
|
||||
`?()` | Applies a filter (script) expression via static evaluation
|
||||
`()` | Script expression via static evaluation
|
||||
|
||||
Given this sample data set, see example expressions below:
|
||||
|
||||
```javascript
|
||||
{
|
||||
"store": {
|
||||
"book": [
|
||||
{
|
||||
"category": "reference",
|
||||
"author": "Nigel Rees",
|
||||
"title": "Sayings of the Century",
|
||||
"price": 8.95
|
||||
}, {
|
||||
"category": "fiction",
|
||||
"author": "Evelyn Waugh",
|
||||
"title": "Sword of Honour",
|
||||
"price": 12.99
|
||||
}, {
|
||||
"category": "fiction",
|
||||
"author": "Herman Melville",
|
||||
"title": "Moby Dick",
|
||||
"isbn": "0-553-21311-3",
|
||||
"price": 8.99
|
||||
}, {
|
||||
"category": "fiction",
|
||||
"author": "J. R. R. Tolkien",
|
||||
"title": "The Lord of the Rings",
|
||||
"isbn": "0-395-19395-8",
|
||||
"price": 22.99
|
||||
}
|
||||
],
|
||||
"bicycle": {
|
||||
"color": "red",
|
||||
"price": 19.95
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Example JSONPath expressions:
|
||||
|
||||
JSONPath | Description
|
||||
------------------------------|------------
|
||||
`$.store.book[*].author` | The authors of all books in the store
|
||||
`$..author` | All authors
|
||||
`$.store.*` | All things in store, which are some books and a red bicycle
|
||||
`$.store..price` | The price of everything in the store
|
||||
`$..book[2]` | The third book
|
||||
`$..book[(@.length-1)]` | The last book via script subscript
|
||||
`$..book[-1:]` | The last book via slice
|
||||
`$..book[0,1]` | The first two books via subscript union
|
||||
`$..book[:2]` | The first two books via subscript array slice
|
||||
`$..book[?(@.isbn)]` | Filter all books with isbn number
|
||||
`$..book[?(@.price<10)]` | Filter all books cheaper than 10
|
||||
`$..book[?(@.price==8.95)]` | Filter all books that cost 8.95
|
||||
`$..book[?(@.price<30 && @.category=="fiction")]` | Filter all fiction books cheaper than 30
|
||||
`$..*` | All members of JSON structure
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
#### jp.query(obj, pathExpression[, count])
|
||||
|
||||
Find elements in `obj` matching `pathExpression`. Returns an array of elements that satisfy the provided JSONPath expression, or an empty array if none were matched. Returns only first `count` elements if specified.
|
||||
|
||||
```javascript
|
||||
var authors = jp.query(data, '$..author');
|
||||
// [ 'Nigel Rees', 'Evelyn Waugh', 'Herman Melville', 'J. R. R. Tolkien' ]
|
||||
```
|
||||
|
||||
#### jp.paths(obj, pathExpression[, count])
|
||||
|
||||
Find paths to elements in `obj` matching `pathExpression`. Returns an array of element paths that satisfy the provided JSONPath expression. Each path is itself an array of keys representing the location within `obj` of the matching element. Returns only first `count` paths if specified.
|
||||
|
||||
|
||||
```javascript
|
||||
var paths = jp.paths(data, '$..author');
|
||||
// [
|
||||
// ['$', 'store', 'book', 0, 'author'] },
|
||||
// ['$', 'store', 'book', 1, 'author'] },
|
||||
// ['$', 'store', 'book', 2, 'author'] },
|
||||
// ['$', 'store', 'book', 3, 'author'] }
|
||||
// ]
|
||||
```
|
||||
|
||||
#### jp.nodes(obj, pathExpression[, count])
|
||||
|
||||
Find elements and their corresponding paths in `obj` matching `pathExpression`. Returns an array of node objects where each node has a `path` containing an array of keys representing the location within `obj`, and a `value` pointing to the matched element. Returns only first `count` nodes if specified.
|
||||
|
||||
```javascript
|
||||
var nodes = jp.nodes(data, '$..author');
|
||||
// [
|
||||
// { path: ['$', 'store', 'book', 0, 'author'], value: 'Nigel Rees' },
|
||||
// { path: ['$', 'store', 'book', 1, 'author'], value: 'Evelyn Waugh' },
|
||||
// { path: ['$', 'store', 'book', 2, 'author'], value: 'Herman Melville' },
|
||||
// { path: ['$', 'store', 'book', 3, 'author'], value: 'J. R. R. Tolkien' }
|
||||
// ]
|
||||
```
|
||||
|
||||
#### jp.value(obj, pathExpression[, newValue])
|
||||
|
||||
Returns the value of the first element matching `pathExpression`. If `newValue` is provided, sets the value of the first matching element and returns the new value.
|
||||
|
||||
#### jp.parent(obj, pathExpression)
|
||||
|
||||
Returns the parent of the first matching element.
|
||||
|
||||
#### jp.apply(obj, pathExpression, fn)
|
||||
|
||||
Runs the supplied function `fn` on each matching element, and replaces each matching element with the return value from the function. The function accepts the value of the matching element as its only parameter. Returns matching nodes with their updated values.
|
||||
|
||||
|
||||
```javascript
|
||||
var nodes = jp.apply(data, '$..author', function(value) { return value.toUpperCase() });
|
||||
// [
|
||||
// { path: ['$', 'store', 'book', 0, 'author'], value: 'NIGEL REES' },
|
||||
// { path: ['$', 'store', 'book', 1, 'author'], value: 'EVELYN WAUGH' },
|
||||
// { path: ['$', 'store', 'book', 2, 'author'], value: 'HERMAN MELVILLE' },
|
||||
// { path: ['$', 'store', 'book', 3, 'author'], value: 'J. R. R. TOLKIEN' }
|
||||
// ]
|
||||
```
|
||||
|
||||
#### jp.parse(pathExpression)
|
||||
|
||||
Parse the provided JSONPath expression into path components and their associated operations.
|
||||
|
||||
```javascript
|
||||
var path = jp.parse('$..author');
|
||||
// [
|
||||
// { expression: { type: 'root', value: '$' } },
|
||||
// { expression: { type: 'identifier', value: 'author' }, operation: 'member', scope: 'descendant' }
|
||||
// ]
|
||||
```
|
||||
|
||||
#### jp.stringify(path)
|
||||
|
||||
Returns a path expression in string form, given a path. The supplied path may either be a flat array of keys, as returned by `jp.nodes` for example, or may alternatively be a fully parsed path expression in the form of an array of path components as returned by `jp.parse`.
|
||||
|
||||
```javascript
|
||||
var pathExpression = jp.stringify(['$', 'store', 'book', 0, 'author']);
|
||||
// "$.store.book[0].author"
|
||||
```
|
||||
|
||||
## Differences from Original Implementation
|
||||
|
||||
This implementation aims to be compatible with Stefan Goessner's original implementation with a few notable exceptions described below.
|
||||
|
||||
#### Evaluating Script Expressions
|
||||
|
||||
Script expressions (i.e, `(...)` and `?(...)`) are statically evaluated via [static-eval](https://github.com/substack/static-eval) rather than using the underlying script engine directly. That means both that the scope is limited to the instance variable (`@`), and only simple expressions (with no side effects) will be valid. So for example, `?(@.length>10)` will be just fine to match arrays with more than ten elements, but `?(process.exit())` will not get evaluated since `process` would yield a `ReferenceError`. This method is even safer than `vm.runInNewContext`, since the script engine itself is more limited and entirely distinct from the one running the application code. See more details in the [implementation](https://github.com/substack/static-eval/blob/master/index.js) of the evaluator.
|
||||
|
||||
#### Grammar
|
||||
|
||||
This project uses a formal BNF [grammar](https://github.com/dchester/jsonpath/blob/master/lib/grammar.js) to parse JSONPath expressions, an attempt at reverse-engineering the intent of the original implementation, which parses via a series of creative regular expressions. The original regex approach can sometimes be forgiving for better or for worse (e.g., `$['store]` => `$['store']`), and in other cases, can be just plain wrong (e.g. `[` => `$`).
|
||||
|
||||
#### Other Minor Differences
|
||||
|
||||
As a result of using a real parser and static evaluation, there are some arguable bugs in the original library that have not been carried through here:
|
||||
|
||||
- strings in subscripts may now be double-quoted
|
||||
- final `step` arguments in slice operators may now be negative
|
||||
- script expressions may now contain `.` and `@` characters not referring to instance variables
|
||||
- subscripts no longer act as character slices on string elements
|
||||
- non-ascii non-word characters are no-longer valid in member identifier names; use quoted subscript strings instead (e.g., `$['$']` instead of `$.$`)
|
||||
- unions now yield real unions with no duplicates rather than concatenated results
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
5
node_modules/jsonpath/fig.yml
generated
vendored
Normal file
5
node_modules/jsonpath/fig.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
test:
|
||||
build: .
|
||||
command: node /usr/src/app/node_modules/.bin/mocha -u tdd test/
|
||||
volumes:
|
||||
- .:/usr/src/app
|
721
node_modules/jsonpath/generated/parser.js
generated
vendored
Normal file
721
node_modules/jsonpath/generated/parser.js
generated
vendored
Normal file
@ -0,0 +1,721 @@
|
||||
/* parser generated by jison 0.4.13 */
|
||||
/*
|
||||
Returns a Parser object of the following structure:
|
||||
|
||||
Parser: {
|
||||
yy: {}
|
||||
}
|
||||
|
||||
Parser.prototype: {
|
||||
yy: {},
|
||||
trace: function(),
|
||||
symbols_: {associative list: name ==> number},
|
||||
terminals_: {associative list: number ==> name},
|
||||
productions_: [...],
|
||||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
||||
table: [...],
|
||||
defaultActions: {...},
|
||||
parseError: function(str, hash),
|
||||
parse: function(input),
|
||||
|
||||
lexer: {
|
||||
EOF: 1,
|
||||
parseError: function(str, hash),
|
||||
setInput: function(input),
|
||||
input: function(),
|
||||
unput: function(str),
|
||||
more: function(),
|
||||
less: function(n),
|
||||
pastInput: function(),
|
||||
upcomingInput: function(),
|
||||
showPosition: function(),
|
||||
test_match: function(regex_match_array, rule_index),
|
||||
next: function(),
|
||||
lex: function(),
|
||||
begin: function(condition),
|
||||
popState: function(),
|
||||
_currentRules: function(),
|
||||
topState: function(),
|
||||
pushState: function(condition),
|
||||
|
||||
options: {
|
||||
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
||||
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
||||
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
||||
},
|
||||
|
||||
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
||||
rules: [...],
|
||||
conditions: {associative list: name ==> set},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
token location info (@$, _$, etc.): {
|
||||
first_line: n,
|
||||
last_line: n,
|
||||
first_column: n,
|
||||
last_column: n,
|
||||
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
||||
}
|
||||
|
||||
|
||||
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
||||
text: (matched text)
|
||||
token: (the produced terminal token, if any)
|
||||
line: (yylineno)
|
||||
}
|
||||
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
||||
loc: (yylloc)
|
||||
expected: (string describing the set of expected tokens)
|
||||
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
||||
}
|
||||
*/
|
||||
var parser = (function(){
|
||||
var parser = {trace: function trace() { },
|
||||
yy: {},
|
||||
symbols_: {"error":2,"JSON_PATH":3,"DOLLAR":4,"PATH_COMPONENTS":5,"LEADING_CHILD_MEMBER_EXPRESSION":6,"PATH_COMPONENT":7,"MEMBER_COMPONENT":8,"SUBSCRIPT_COMPONENT":9,"CHILD_MEMBER_COMPONENT":10,"DESCENDANT_MEMBER_COMPONENT":11,"DOT":12,"MEMBER_EXPRESSION":13,"DOT_DOT":14,"STAR":15,"IDENTIFIER":16,"SCRIPT_EXPRESSION":17,"INTEGER":18,"END":19,"CHILD_SUBSCRIPT_COMPONENT":20,"DESCENDANT_SUBSCRIPT_COMPONENT":21,"[":22,"SUBSCRIPT":23,"]":24,"SUBSCRIPT_EXPRESSION":25,"SUBSCRIPT_EXPRESSION_LIST":26,"SUBSCRIPT_EXPRESSION_LISTABLE":27,",":28,"STRING_LITERAL":29,"ARRAY_SLICE":30,"FILTER_EXPRESSION":31,"QQ_STRING":32,"Q_STRING":33,"$accept":0,"$end":1},
|
||||
terminals_: {2:"error",4:"DOLLAR",12:"DOT",14:"DOT_DOT",15:"STAR",16:"IDENTIFIER",17:"SCRIPT_EXPRESSION",18:"INTEGER",19:"END",22:"[",24:"]",28:",",30:"ARRAY_SLICE",31:"FILTER_EXPRESSION",32:"QQ_STRING",33:"Q_STRING"},
|
||||
productions_: [0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],
|
||||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */
|
||||
/**/) {
|
||||
/* this == yyval */
|
||||
if (!yy.ast) {
|
||||
yy.ast = _ast;
|
||||
_ast.initialize();
|
||||
}
|
||||
|
||||
var $0 = $$.length - 1;
|
||||
switch (yystate) {
|
||||
case 1:yy.ast.set({ expression: { type: "root", value: $$[$0] } }); yy.ast.unshift(); return yy.ast.yield()
|
||||
break;
|
||||
case 2:yy.ast.set({ expression: { type: "root", value: $$[$0-1] } }); yy.ast.unshift(); return yy.ast.yield()
|
||||
break;
|
||||
case 3:yy.ast.unshift(); return yy.ast.yield()
|
||||
break;
|
||||
case 4:yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $$[$0-1] }}); yy.ast.unshift(); return yy.ast.yield()
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:yy.ast.set({ operation: "member" }); yy.ast.push()
|
||||
break;
|
||||
case 8:yy.ast.set({ operation: "subscript" }); yy.ast.push()
|
||||
break;
|
||||
case 9:yy.ast.set({ scope: "child" })
|
||||
break;
|
||||
case 10:yy.ast.set({ scope: "descendant" })
|
||||
break;
|
||||
case 11:
|
||||
break;
|
||||
case 12:yy.ast.set({ scope: "child", operation: "member" })
|
||||
break;
|
||||
case 13:
|
||||
break;
|
||||
case 14:yy.ast.set({ expression: { type: "wildcard", value: $$[$0] } })
|
||||
break;
|
||||
case 15:yy.ast.set({ expression: { type: "identifier", value: $$[$0] } })
|
||||
break;
|
||||
case 16:yy.ast.set({ expression: { type: "script_expression", value: $$[$0] } })
|
||||
break;
|
||||
case 17:yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($$[$0]) } })
|
||||
break;
|
||||
case 18:
|
||||
break;
|
||||
case 19:yy.ast.set({ scope: "child" })
|
||||
break;
|
||||
case 20:yy.ast.set({ scope: "descendant" })
|
||||
break;
|
||||
case 21:
|
||||
break;
|
||||
case 22:
|
||||
break;
|
||||
case 23:
|
||||
break;
|
||||
case 24:$$[$0].length > 1? yy.ast.set({ expression: { type: "union", value: $$[$0] } }) : this.$ = $$[$0]
|
||||
break;
|
||||
case 25:this.$ = [$$[$0]]
|
||||
break;
|
||||
case 26:this.$ = $$[$0-2].concat($$[$0])
|
||||
break;
|
||||
case 27:this.$ = { expression: { type: "numeric_literal", value: parseInt($$[$0]) } }; yy.ast.set(this.$)
|
||||
break;
|
||||
case 28:this.$ = { expression: { type: "string_literal", value: $$[$0] } }; yy.ast.set(this.$)
|
||||
break;
|
||||
case 29:this.$ = { expression: { type: "slice", value: $$[$0] } }; yy.ast.set(this.$)
|
||||
break;
|
||||
case 30:this.$ = { expression: { type: "wildcard", value: $$[$0] } }; yy.ast.set(this.$)
|
||||
break;
|
||||
case 31:this.$ = { expression: { type: "script_expression", value: $$[$0] } }; yy.ast.set(this.$)
|
||||
break;
|
||||
case 32:this.$ = { expression: { type: "filter_expression", value: $$[$0] } }; yy.ast.set(this.$)
|
||||
break;
|
||||
case 33:this.$ = $$[$0]
|
||||
break;
|
||||
case 34:this.$ = $$[$0]
|
||||
break;
|
||||
}
|
||||
},
|
||||
table: [{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],
|
||||
defaultActions: {27:[2,23],29:[2,30],30:[2,31],31:[2,32]},
|
||||
parseError: function parseError(str, hash) {
|
||||
if (hash.recoverable) {
|
||||
this.trace(str);
|
||||
} else {
|
||||
throw new Error(str);
|
||||
}
|
||||
},
|
||||
parse: function parse(input) {
|
||||
var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
||||
var args = lstack.slice.call(arguments, 1);
|
||||
this.lexer.setInput(input);
|
||||
this.lexer.yy = this.yy;
|
||||
this.yy.lexer = this.lexer;
|
||||
this.yy.parser = this;
|
||||
if (typeof this.lexer.yylloc == 'undefined') {
|
||||
this.lexer.yylloc = {};
|
||||
}
|
||||
var yyloc = this.lexer.yylloc;
|
||||
lstack.push(yyloc);
|
||||
var ranges = this.lexer.options && this.lexer.options.ranges;
|
||||
if (typeof this.yy.parseError === 'function') {
|
||||
this.parseError = this.yy.parseError;
|
||||
} else {
|
||||
this.parseError = Object.getPrototypeOf(this).parseError;
|
||||
}
|
||||
function popStack(n) {
|
||||
stack.length = stack.length - 2 * n;
|
||||
vstack.length = vstack.length - n;
|
||||
lstack.length = lstack.length - n;
|
||||
}
|
||||
function lex() {
|
||||
var token;
|
||||
token = self.lexer.lex() || EOF;
|
||||
if (typeof token !== 'number') {
|
||||
token = self.symbols_[token] || token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
||||
while (true) {
|
||||
state = stack[stack.length - 1];
|
||||
if (this.defaultActions[state]) {
|
||||
action = this.defaultActions[state];
|
||||
} else {
|
||||
if (symbol === null || typeof symbol == 'undefined') {
|
||||
symbol = lex();
|
||||
}
|
||||
action = table[state] && table[state][symbol];
|
||||
}
|
||||
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
||||
var errStr = '';
|
||||
expected = [];
|
||||
for (p in table[state]) {
|
||||
if (this.terminals_[p] && p > TERROR) {
|
||||
expected.push('\'' + this.terminals_[p] + '\'');
|
||||
}
|
||||
}
|
||||
if (this.lexer.showPosition) {
|
||||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + this.lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
||||
} else {
|
||||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
||||
}
|
||||
this.parseError(errStr, {
|
||||
text: this.lexer.match,
|
||||
token: this.terminals_[symbol] || symbol,
|
||||
line: this.lexer.yylineno,
|
||||
loc: yyloc,
|
||||
expected: expected
|
||||
});
|
||||
}
|
||||
if (action[0] instanceof Array && action.length > 1) {
|
||||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
||||
}
|
||||
switch (action[0]) {
|
||||
case 1:
|
||||
stack.push(symbol);
|
||||
vstack.push(this.lexer.yytext);
|
||||
lstack.push(this.lexer.yylloc);
|
||||
stack.push(action[1]);
|
||||
symbol = null;
|
||||
if (!preErrorSymbol) {
|
||||
yyleng = this.lexer.yyleng;
|
||||
yytext = this.lexer.yytext;
|
||||
yylineno = this.lexer.yylineno;
|
||||
yyloc = this.lexer.yylloc;
|
||||
if (recovering > 0) {
|
||||
recovering--;
|
||||
}
|
||||
} else {
|
||||
symbol = preErrorSymbol;
|
||||
preErrorSymbol = null;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
len = this.productions_[action[1]][1];
|
||||
yyval.$ = vstack[vstack.length - len];
|
||||
yyval._$ = {
|
||||
first_line: lstack[lstack.length - (len || 1)].first_line,
|
||||
last_line: lstack[lstack.length - 1].last_line,
|
||||
first_column: lstack[lstack.length - (len || 1)].first_column,
|
||||
last_column: lstack[lstack.length - 1].last_column
|
||||
};
|
||||
if (ranges) {
|
||||
yyval._$.range = [
|
||||
lstack[lstack.length - (len || 1)].range[0],
|
||||
lstack[lstack.length - 1].range[1]
|
||||
];
|
||||
}
|
||||
r = this.performAction.apply(yyval, [
|
||||
yytext,
|
||||
yyleng,
|
||||
yylineno,
|
||||
this.yy,
|
||||
action[1],
|
||||
vstack,
|
||||
lstack
|
||||
].concat(args));
|
||||
if (typeof r !== 'undefined') {
|
||||
return r;
|
||||
}
|
||||
if (len) {
|
||||
stack = stack.slice(0, -1 * len * 2);
|
||||
vstack = vstack.slice(0, -1 * len);
|
||||
lstack = lstack.slice(0, -1 * len);
|
||||
}
|
||||
stack.push(this.productions_[action[1]][0]);
|
||||
vstack.push(yyval.$);
|
||||
lstack.push(yyval._$);
|
||||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
||||
stack.push(newState);
|
||||
break;
|
||||
case 3:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}};
|
||||
var _ast = {
|
||||
|
||||
initialize: function() {
|
||||
this._nodes = [];
|
||||
this._node = {};
|
||||
this._stash = [];
|
||||
},
|
||||
|
||||
set: function(props) {
|
||||
for (var k in props) this._node[k] = props[k];
|
||||
return this._node;
|
||||
},
|
||||
|
||||
node: function(obj) {
|
||||
if (arguments.length) this._node = obj;
|
||||
return this._node;
|
||||
},
|
||||
|
||||
push: function() {
|
||||
this._nodes.push(this._node);
|
||||
this._node = {};
|
||||
},
|
||||
|
||||
unshift: function() {
|
||||
this._nodes.unshift(this._node);
|
||||
this._node = {};
|
||||
},
|
||||
|
||||
yield: function() {
|
||||
var _nodes = this._nodes;
|
||||
this.initialize();
|
||||
return _nodes;
|
||||
}
|
||||
};
|
||||
/* generated by jison-lex 0.2.1 */
|
||||
var lexer = (function(){
|
||||
var lexer = {
|
||||
|
||||
EOF:1,
|
||||
|
||||
parseError:function parseError(str, hash) {
|
||||
if (this.yy.parser) {
|
||||
this.yy.parser.parseError(str, hash);
|
||||
} else {
|
||||
throw new Error(str);
|
||||
}
|
||||
},
|
||||
|
||||
// resets the lexer, sets new input
|
||||
setInput:function (input) {
|
||||
this._input = input;
|
||||
this._more = this._backtrack = this.done = false;
|
||||
this.yylineno = this.yyleng = 0;
|
||||
this.yytext = this.matched = this.match = '';
|
||||
this.conditionStack = ['INITIAL'];
|
||||
this.yylloc = {
|
||||
first_line: 1,
|
||||
first_column: 0,
|
||||
last_line: 1,
|
||||
last_column: 0
|
||||
};
|
||||
if (this.options.ranges) {
|
||||
this.yylloc.range = [0,0];
|
||||
}
|
||||
this.offset = 0;
|
||||
return this;
|
||||
},
|
||||
|
||||
// consumes and returns one char from the input
|
||||
input:function () {
|
||||
var ch = this._input[0];
|
||||
this.yytext += ch;
|
||||
this.yyleng++;
|
||||
this.offset++;
|
||||
this.match += ch;
|
||||
this.matched += ch;
|
||||
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
||||
if (lines) {
|
||||
this.yylineno++;
|
||||
this.yylloc.last_line++;
|
||||
} else {
|
||||
this.yylloc.last_column++;
|
||||
}
|
||||
if (this.options.ranges) {
|
||||
this.yylloc.range[1]++;
|
||||
}
|
||||
|
||||
this._input = this._input.slice(1);
|
||||
return ch;
|
||||
},
|
||||
|
||||
// unshifts one char (or a string) into the input
|
||||
unput:function (ch) {
|
||||
var len = ch.length;
|
||||
var lines = ch.split(/(?:\r\n?|\n)/g);
|
||||
|
||||
this._input = ch + this._input;
|
||||
this.yytext = this.yytext.substr(0, this.yytext.length - len - 1);
|
||||
//this.yyleng -= len;
|
||||
this.offset -= len;
|
||||
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
||||
this.match = this.match.substr(0, this.match.length - 1);
|
||||
this.matched = this.matched.substr(0, this.matched.length - 1);
|
||||
|
||||
if (lines.length - 1) {
|
||||
this.yylineno -= lines.length - 1;
|
||||
}
|
||||
var r = this.yylloc.range;
|
||||
|
||||
this.yylloc = {
|
||||
first_line: this.yylloc.first_line,
|
||||
last_line: this.yylineno + 1,
|
||||
first_column: this.yylloc.first_column,
|
||||
last_column: lines ?
|
||||
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
||||
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
|
||||
this.yylloc.first_column - len
|
||||
};
|
||||
|
||||
if (this.options.ranges) {
|
||||
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
||||
}
|
||||
this.yyleng = this.yytext.length;
|
||||
return this;
|
||||
},
|
||||
|
||||
// When called from action, caches matched text and appends it on next action
|
||||
more:function () {
|
||||
this._more = true;
|
||||
return this;
|
||||
},
|
||||
|
||||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
||||
reject:function () {
|
||||
if (this.options.backtrack_lexer) {
|
||||
this._backtrack = true;
|
||||
} else {
|
||||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
||||
text: "",
|
||||
token: null,
|
||||
line: this.yylineno
|
||||
});
|
||||
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// retain first n characters of the match
|
||||
less:function (n) {
|
||||
this.unput(this.match.slice(n));
|
||||
},
|
||||
|
||||
// displays already matched input, i.e. for error messages
|
||||
pastInput:function () {
|
||||
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
||||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
||||
},
|
||||
|
||||
// displays upcoming input, i.e. for error messages
|
||||
upcomingInput:function () {
|
||||
var next = this.match;
|
||||
if (next.length < 20) {
|
||||
next += this._input.substr(0, 20-next.length);
|
||||
}
|
||||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
||||
},
|
||||
|
||||
// displays the character position where the lexing error occurred, i.e. for error messages
|
||||
showPosition:function () {
|
||||
var pre = this.pastInput();
|
||||
var c = new Array(pre.length + 1).join("-");
|
||||
return pre + this.upcomingInput() + "\n" + c + "^";
|
||||
},
|
||||
|
||||
// test the lexed token: return FALSE when not a match, otherwise return token
|
||||
test_match:function (match, indexed_rule) {
|
||||
var token,
|
||||
lines,
|
||||
backup;
|
||||
|
||||
if (this.options.backtrack_lexer) {
|
||||
// save context
|
||||
backup = {
|
||||
yylineno: this.yylineno,
|
||||
yylloc: {
|
||||
first_line: this.yylloc.first_line,
|
||||
last_line: this.last_line,
|
||||
first_column: this.yylloc.first_column,
|
||||
last_column: this.yylloc.last_column
|
||||
},
|
||||
yytext: this.yytext,
|
||||
match: this.match,
|
||||
matches: this.matches,
|
||||
matched: this.matched,
|
||||
yyleng: this.yyleng,
|
||||
offset: this.offset,
|
||||
_more: this._more,
|
||||
_input: this._input,
|
||||
yy: this.yy,
|
||||
conditionStack: this.conditionStack.slice(0),
|
||||
done: this.done
|
||||
};
|
||||
if (this.options.ranges) {
|
||||
backup.yylloc.range = this.yylloc.range.slice(0);
|
||||
}
|
||||
}
|
||||
|
||||
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
||||
if (lines) {
|
||||
this.yylineno += lines.length;
|
||||
}
|
||||
this.yylloc = {
|
||||
first_line: this.yylloc.last_line,
|
||||
last_line: this.yylineno + 1,
|
||||
first_column: this.yylloc.last_column,
|
||||
last_column: lines ?
|
||||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
||||
this.yylloc.last_column + match[0].length
|
||||
};
|
||||
this.yytext += match[0];
|
||||
this.match += match[0];
|
||||
this.matches = match;
|
||||
this.yyleng = this.yytext.length;
|
||||
if (this.options.ranges) {
|
||||
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
||||
}
|
||||
this._more = false;
|
||||
this._backtrack = false;
|
||||
this._input = this._input.slice(match[0].length);
|
||||
this.matched += match[0];
|
||||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
||||
if (this.done && this._input) {
|
||||
this.done = false;
|
||||
}
|
||||
if (token) {
|
||||
return token;
|
||||
} else if (this._backtrack) {
|
||||
// recover context
|
||||
for (var k in backup) {
|
||||
this[k] = backup[k];
|
||||
}
|
||||
return false; // rule action called reject() implying the next rule should be tested instead.
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// return next match in input
|
||||
next:function () {
|
||||
if (this.done) {
|
||||
return this.EOF;
|
||||
}
|
||||
if (!this._input) {
|
||||
this.done = true;
|
||||
}
|
||||
|
||||
var token,
|
||||
match,
|
||||
tempMatch,
|
||||
index;
|
||||
if (!this._more) {
|
||||
this.yytext = '';
|
||||
this.match = '';
|
||||
}
|
||||
var rules = this._currentRules();
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
tempMatch = this._input.match(this.rules[rules[i]]);
|
||||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
||||
match = tempMatch;
|
||||
index = i;
|
||||
if (this.options.backtrack_lexer) {
|
||||
token = this.test_match(tempMatch, rules[i]);
|
||||
if (token !== false) {
|
||||
return token;
|
||||
} else if (this._backtrack) {
|
||||
match = false;
|
||||
continue; // rule action called reject() implying a rule MISmatch.
|
||||
} else {
|
||||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
||||
return false;
|
||||
}
|
||||
} else if (!this.options.flex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
token = this.test_match(match, rules[index]);
|
||||
if (token !== false) {
|
||||
return token;
|
||||
}
|
||||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
||||
return false;
|
||||
}
|
||||
if (this._input === "") {
|
||||
return this.EOF;
|
||||
} else {
|
||||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
||||
text: "",
|
||||
token: null,
|
||||
line: this.yylineno
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// return next match that has a token
|
||||
lex:function lex() {
|
||||
var r = this.next();
|
||||
if (r) {
|
||||
return r;
|
||||
} else {
|
||||
return this.lex();
|
||||
}
|
||||
},
|
||||
|
||||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
||||
begin:function begin(condition) {
|
||||
this.conditionStack.push(condition);
|
||||
},
|
||||
|
||||
// pop the previously active lexer condition state off the condition stack
|
||||
popState:function popState() {
|
||||
var n = this.conditionStack.length - 1;
|
||||
if (n > 0) {
|
||||
return this.conditionStack.pop();
|
||||
} else {
|
||||
return this.conditionStack[0];
|
||||
}
|
||||
},
|
||||
|
||||
// produce the lexer rule set which is active for the currently active lexer condition state
|
||||
_currentRules:function _currentRules() {
|
||||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
||||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
||||
} else {
|
||||
return this.conditions["INITIAL"].rules;
|
||||
}
|
||||
},
|
||||
|
||||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
||||
topState:function topState(n) {
|
||||
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
||||
if (n >= 0) {
|
||||
return this.conditionStack[n];
|
||||
} else {
|
||||
return "INITIAL";
|
||||
}
|
||||
},
|
||||
|
||||
// alias for begin(condition)
|
||||
pushState:function pushState(condition) {
|
||||
this.begin(condition);
|
||||
},
|
||||
|
||||
// return the number of states currently on the stack
|
||||
stateStackSize:function stateStackSize() {
|
||||
return this.conditionStack.length;
|
||||
},
|
||||
options: {},
|
||||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START
|
||||
/**/) {
|
||||
|
||||
var YYSTATE=YY_START;
|
||||
switch($avoiding_name_collisions) {
|
||||
case 0:return 4
|
||||
break;
|
||||
case 1:return 14
|
||||
break;
|
||||
case 2:return 12
|
||||
break;
|
||||
case 3:return 15
|
||||
break;
|
||||
case 4:return 16
|
||||
break;
|
||||
case 5:return 22
|
||||
break;
|
||||
case 6:return 24
|
||||
break;
|
||||
case 7:return 28
|
||||
break;
|
||||
case 8:return 30
|
||||
break;
|
||||
case 9:return 18
|
||||
break;
|
||||
case 10:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 32;
|
||||
break;
|
||||
case 11:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 33;
|
||||
break;
|
||||
case 12:return 17
|
||||
break;
|
||||
case 13:return 31
|
||||
break;
|
||||
}
|
||||
},
|
||||
rules: [/^(?:\$)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\:((-?(?:0|[1-9][0-9]*)))?(\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*")/,/^(?:'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*')/,/^(?:\(.+?\)(?=\]))/,/^(?:\?\(.+?\)(?=\]))/],
|
||||
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}}
|
||||
};
|
||||
return lexer;
|
||||
})();
|
||||
parser.lexer = lexer;
|
||||
function Parser () {
|
||||
this.yy = {};
|
||||
}
|
||||
Parser.prototype = parser;parser.Parser = Parser;
|
||||
return new Parser;
|
||||
})();
|
||||
|
||||
|
||||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
||||
exports.parser = parser;
|
||||
exports.Parser = parser.Parser;
|
||||
exports.parse = function () { return parser.parse.apply(parser, arguments); };
|
||||
exports.main = function commonjsMain(args) {
|
||||
if (!args[1]) {
|
||||
console.log('Usage: '+args[0]+' FILE');
|
||||
process.exit(1);
|
||||
}
|
||||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
||||
return exports.parser.parse(source);
|
||||
};
|
||||
if (typeof module !== 'undefined' && require.main === module) {
|
||||
exports.main(process.argv.slice(1));
|
||||
}
|
||||
}
|
4
node_modules/jsonpath/include/action.js
generated
vendored
Normal file
4
node_modules/jsonpath/include/action.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
if (!yy.ast) {
|
||||
yy.ast = _ast;
|
||||
_ast.initialize();
|
||||
}
|
34
node_modules/jsonpath/include/module.js
generated
vendored
Normal file
34
node_modules/jsonpath/include/module.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
var _ast = {
|
||||
|
||||
initialize: function() {
|
||||
this._nodes = [];
|
||||
this._node = {};
|
||||
this._stash = [];
|
||||
},
|
||||
|
||||
set: function(props) {
|
||||
for (var k in props) this._node[k] = props[k];
|
||||
return this._node;
|
||||
},
|
||||
|
||||
node: function(obj) {
|
||||
if (arguments.length) this._node = obj;
|
||||
return this._node;
|
||||
},
|
||||
|
||||
push: function() {
|
||||
this._nodes.push(this._node);
|
||||
this._node = {};
|
||||
},
|
||||
|
||||
unshift: function() {
|
||||
this._nodes.unshift(this._node);
|
||||
this._node = {};
|
||||
},
|
||||
|
||||
yield: function() {
|
||||
var _nodes = this._nodes;
|
||||
this.initialize();
|
||||
return _nodes;
|
||||
}
|
||||
};
|
1
node_modules/jsonpath/index.js
generated
vendored
Normal file
1
node_modules/jsonpath/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./lib/index');
|
6842
node_modules/jsonpath/jsonpath.js
generated
vendored
Normal file
6842
node_modules/jsonpath/jsonpath.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/jsonpath/jsonpath.min.js
generated
vendored
Normal file
4
node_modules/jsonpath/jsonpath.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
node_modules/jsonpath/lib/aesprim.js
generated
vendored
Normal file
18
node_modules/jsonpath/lib/aesprim.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var fs = require('fs');
|
||||
var Module = require('module');
|
||||
|
||||
var file = require.resolve('esprima');
|
||||
var source = fs.readFileSync(file, 'utf-8');
|
||||
|
||||
// inject '@' as a valid identifier!
|
||||
source = source.replace(/(function isIdentifierStart\(ch\) {\s+return)/m, '$1 (ch == 0x40) || ');
|
||||
|
||||
//If run as script just output patched file
|
||||
if (require.main === module)
|
||||
console.log(source);
|
||||
else {
|
||||
var _module = new Module('aesprim');
|
||||
_module._compile(source, __filename);
|
||||
|
||||
module.exports = _module.exports;
|
||||
}
|
6
node_modules/jsonpath/lib/dict.js
generated
vendored
Normal file
6
node_modules/jsonpath/lib/dict.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
identifier: "[a-zA-Z_]+[a-zA-Z0-9_]*",
|
||||
integer: "-?(?:0|[1-9][0-9]*)",
|
||||
qq_string: "\"(?:\\\\[\"bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\"\\\\])*\"",
|
||||
q_string: "'(?:\\\\[\'bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\'\\\\])*'"
|
||||
};
|
106
node_modules/jsonpath/lib/grammar.js
generated
vendored
Normal file
106
node_modules/jsonpath/lib/grammar.js
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
var dict = require('./dict');
|
||||
var fs = require('fs');
|
||||
var grammar = {
|
||||
|
||||
lex: {
|
||||
|
||||
macros: {
|
||||
esc: "\\\\",
|
||||
int: dict.integer
|
||||
},
|
||||
|
||||
rules: [
|
||||
["\\$", "return 'DOLLAR'"],
|
||||
["\\.\\.", "return 'DOT_DOT'"],
|
||||
["\\.", "return 'DOT'"],
|
||||
["\\*", "return 'STAR'"],
|
||||
[dict.identifier, "return 'IDENTIFIER'"],
|
||||
["\\[", "return '['"],
|
||||
["\\]", "return ']'"],
|
||||
[",", "return ','"],
|
||||
["({int})?\\:({int})?(\\:({int})?)?", "return 'ARRAY_SLICE'"],
|
||||
["{int}", "return 'INTEGER'"],
|
||||
[dict.qq_string, "yytext = yytext.substr(1,yyleng-2); return 'QQ_STRING';"],
|
||||
[dict.q_string, "yytext = yytext.substr(1,yyleng-2); return 'Q_STRING';"],
|
||||
["\\(.+?\\)(?=\\])", "return 'SCRIPT_EXPRESSION'"],
|
||||
["\\?\\(.+?\\)(?=\\])", "return 'FILTER_EXPRESSION'"]
|
||||
]
|
||||
},
|
||||
|
||||
start: "JSON_PATH",
|
||||
|
||||
bnf: {
|
||||
|
||||
JSON_PATH: [
|
||||
[ 'DOLLAR', 'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()' ],
|
||||
[ 'DOLLAR PATH_COMPONENTS', 'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()' ],
|
||||
[ 'LEADING_CHILD_MEMBER_EXPRESSION', 'yy.ast.unshift(); return yy.ast.yield()' ],
|
||||
[ 'LEADING_CHILD_MEMBER_EXPRESSION PATH_COMPONENTS', 'yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $1 }}); yy.ast.unshift(); return yy.ast.yield()' ] ],
|
||||
|
||||
PATH_COMPONENTS: [
|
||||
[ 'PATH_COMPONENT', '' ],
|
||||
[ 'PATH_COMPONENTS PATH_COMPONENT', '' ] ],
|
||||
|
||||
PATH_COMPONENT: [
|
||||
[ 'MEMBER_COMPONENT', 'yy.ast.set({ operation: "member" }); yy.ast.push()' ],
|
||||
[ 'SUBSCRIPT_COMPONENT', 'yy.ast.set({ operation: "subscript" }); yy.ast.push() ' ] ],
|
||||
|
||||
MEMBER_COMPONENT: [
|
||||
[ 'CHILD_MEMBER_COMPONENT', 'yy.ast.set({ scope: "child" })' ],
|
||||
[ 'DESCENDANT_MEMBER_COMPONENT', 'yy.ast.set({ scope: "descendant" })' ] ],
|
||||
|
||||
CHILD_MEMBER_COMPONENT: [
|
||||
[ 'DOT MEMBER_EXPRESSION', '' ] ],
|
||||
|
||||
LEADING_CHILD_MEMBER_EXPRESSION: [
|
||||
[ 'MEMBER_EXPRESSION', 'yy.ast.set({ scope: "child", operation: "member" })' ] ],
|
||||
|
||||
DESCENDANT_MEMBER_COMPONENT: [
|
||||
[ 'DOT_DOT MEMBER_EXPRESSION', '' ] ],
|
||||
|
||||
MEMBER_EXPRESSION: [
|
||||
[ 'STAR', 'yy.ast.set({ expression: { type: "wildcard", value: $1 } })' ],
|
||||
[ 'IDENTIFIER', 'yy.ast.set({ expression: { type: "identifier", value: $1 } })' ],
|
||||
[ 'SCRIPT_EXPRESSION', 'yy.ast.set({ expression: { type: "script_expression", value: $1 } })' ],
|
||||
[ 'INTEGER', 'yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($1) } })' ],
|
||||
[ 'END', '' ] ],
|
||||
|
||||
SUBSCRIPT_COMPONENT: [
|
||||
[ 'CHILD_SUBSCRIPT_COMPONENT', 'yy.ast.set({ scope: "child" })' ],
|
||||
[ 'DESCENDANT_SUBSCRIPT_COMPONENT', 'yy.ast.set({ scope: "descendant" })' ] ],
|
||||
|
||||
CHILD_SUBSCRIPT_COMPONENT: [
|
||||
[ '[ SUBSCRIPT ]', '' ] ],
|
||||
|
||||
DESCENDANT_SUBSCRIPT_COMPONENT: [
|
||||
[ 'DOT_DOT [ SUBSCRIPT ]', '' ] ],
|
||||
|
||||
SUBSCRIPT: [
|
||||
[ 'SUBSCRIPT_EXPRESSION', '' ],
|
||||
[ 'SUBSCRIPT_EXPRESSION_LIST', '$1.length > 1? yy.ast.set({ expression: { type: "union", value: $1 } }) : $$ = $1' ] ],
|
||||
|
||||
SUBSCRIPT_EXPRESSION_LIST: [
|
||||
[ 'SUBSCRIPT_EXPRESSION_LISTABLE', '$$ = [$1]'],
|
||||
[ 'SUBSCRIPT_EXPRESSION_LIST , SUBSCRIPT_EXPRESSION_LISTABLE', '$$ = $1.concat($3)' ] ],
|
||||
|
||||
SUBSCRIPT_EXPRESSION_LISTABLE: [
|
||||
[ 'INTEGER', '$$ = { expression: { type: "numeric_literal", value: parseInt($1) } }; yy.ast.set($$)' ],
|
||||
[ 'STRING_LITERAL', '$$ = { expression: { type: "string_literal", value: $1 } }; yy.ast.set($$)' ],
|
||||
[ 'ARRAY_SLICE', '$$ = { expression: { type: "slice", value: $1 } }; yy.ast.set($$)' ] ],
|
||||
|
||||
SUBSCRIPT_EXPRESSION: [
|
||||
[ 'STAR', '$$ = { expression: { type: "wildcard", value: $1 } }; yy.ast.set($$)' ],
|
||||
[ 'SCRIPT_EXPRESSION', '$$ = { expression: { type: "script_expression", value: $1 } }; yy.ast.set($$)' ],
|
||||
[ 'FILTER_EXPRESSION', '$$ = { expression: { type: "filter_expression", value: $1 } }; yy.ast.set($$)' ] ],
|
||||
|
||||
STRING_LITERAL: [
|
||||
[ 'QQ_STRING', "$$ = $1" ],
|
||||
[ 'Q_STRING', "$$ = $1" ] ]
|
||||
}
|
||||
};
|
||||
if (fs.readFileSync) {
|
||||
grammar.moduleInclude = fs.readFileSync(require.resolve("../include/module.js"));
|
||||
grammar.actionInclude = fs.readFileSync(require.resolve("../include/action.js"));
|
||||
}
|
||||
|
||||
module.exports = grammar;
|
260
node_modules/jsonpath/lib/handlers.js
generated
vendored
Normal file
260
node_modules/jsonpath/lib/handlers.js
generated
vendored
Normal file
@ -0,0 +1,260 @@
|
||||
var aesprim = require('./aesprim');
|
||||
var slice = require('./slice');
|
||||
var _evaluate = require('static-eval');
|
||||
var _uniq = require('underscore').uniq;
|
||||
|
||||
var Handlers = function() {
|
||||
return this.initialize.apply(this, arguments);
|
||||
}
|
||||
|
||||
Handlers.prototype.initialize = function() {
|
||||
this.traverse = traverser(true);
|
||||
this.descend = traverser();
|
||||
}
|
||||
|
||||
Handlers.prototype.keys = Object.keys;
|
||||
|
||||
Handlers.prototype.resolve = function(component) {
|
||||
|
||||
var key = [ component.operation, component.scope, component.expression.type ].join('-');
|
||||
var method = this._fns[key];
|
||||
|
||||
if (!method) throw new Error("couldn't resolve key: " + key);
|
||||
return method.bind(this);
|
||||
};
|
||||
|
||||
Handlers.prototype.register = function(key, handler) {
|
||||
|
||||
if (!handler instanceof Function) {
|
||||
throw new Error("handler must be a function");
|
||||
}
|
||||
|
||||
this._fns[key] = handler;
|
||||
};
|
||||
|
||||
Handlers.prototype._fns = {
|
||||
|
||||
'member-child-identifier': function(component, partial) {
|
||||
var key = component.expression.value;
|
||||
var value = partial.value;
|
||||
if (value instanceof Object && key in value) {
|
||||
return [ { value: value[key], path: partial.path.concat(key) } ]
|
||||
}
|
||||
},
|
||||
|
||||
'member-descendant-identifier':
|
||||
_traverse(function(key, value, ref) { return key == ref }),
|
||||
|
||||
'subscript-child-numeric_literal':
|
||||
_descend(function(key, value, ref) { return key === ref }),
|
||||
|
||||
'member-child-numeric_literal':
|
||||
_descend(function(key, value, ref) { return String(key) === String(ref) }),
|
||||
|
||||
'subscript-descendant-numeric_literal':
|
||||
_traverse(function(key, value, ref) { return key === ref }),
|
||||
|
||||
'member-child-wildcard':
|
||||
_descend(function() { return true }),
|
||||
|
||||
'member-descendant-wildcard':
|
||||
_traverse(function() { return true }),
|
||||
|
||||
'subscript-descendant-wildcard':
|
||||
_traverse(function() { return true }),
|
||||
|
||||
'subscript-child-wildcard':
|
||||
_descend(function() { return true }),
|
||||
|
||||
'subscript-child-slice': function(component, partial) {
|
||||
if (is_array(partial.value)) {
|
||||
var args = component.expression.value.split(':').map(_parse_nullable_int);
|
||||
var values = partial.value.map(function(v, i) { return { value: v, path: partial.path.concat(i) } });
|
||||
return slice.apply(null, [values].concat(args));
|
||||
}
|
||||
},
|
||||
|
||||
'subscript-child-union': function(component, partial) {
|
||||
var results = [];
|
||||
component.expression.value.forEach(function(component) {
|
||||
var _component = { operation: 'subscript', scope: 'child', expression: component.expression };
|
||||
var handler = this.resolve(_component);
|
||||
var _results = handler(_component, partial);
|
||||
if (_results) {
|
||||
results = results.concat(_results);
|
||||
}
|
||||
}, this);
|
||||
|
||||
return unique(results);
|
||||
},
|
||||
|
||||
'subscript-descendant-union': function(component, partial, count) {
|
||||
|
||||
var jp = require('..');
|
||||
var self = this;
|
||||
|
||||
var results = [];
|
||||
var nodes = jp.nodes(partial, '$..*').slice(1);
|
||||
|
||||
nodes.forEach(function(node) {
|
||||
if (results.length >= count) return;
|
||||
component.expression.value.forEach(function(component) {
|
||||
var _component = { operation: 'subscript', scope: 'child', expression: component.expression };
|
||||
var handler = self.resolve(_component);
|
||||
var _results = handler(_component, node);
|
||||
results = results.concat(_results);
|
||||
});
|
||||
});
|
||||
|
||||
return unique(results);
|
||||
},
|
||||
|
||||
'subscript-child-filter_expression': function(component, partial, count) {
|
||||
|
||||
// slice out the expression from ?(expression)
|
||||
var src = component.expression.value.slice(2, -1);
|
||||
var ast = aesprim.parse(src).body[0].expression;
|
||||
|
||||
var passable = function(key, value) {
|
||||
return evaluate(ast, { '@': value });
|
||||
}
|
||||
|
||||
return this.descend(partial, null, passable, count);
|
||||
|
||||
},
|
||||
|
||||
'subscript-descendant-filter_expression': function(component, partial, count) {
|
||||
|
||||
// slice out the expression from ?(expression)
|
||||
var src = component.expression.value.slice(2, -1);
|
||||
var ast = aesprim.parse(src).body[0].expression;
|
||||
|
||||
var passable = function(key, value) {
|
||||
return evaluate(ast, { '@': value });
|
||||
}
|
||||
|
||||
return this.traverse(partial, null, passable, count);
|
||||
},
|
||||
|
||||
'subscript-child-script_expression': function(component, partial) {
|
||||
var exp = component.expression.value.slice(1, -1);
|
||||
return eval_recurse(partial, exp, '$[{{value}}]');
|
||||
},
|
||||
|
||||
'member-child-script_expression': function(component, partial) {
|
||||
var exp = component.expression.value.slice(1, -1);
|
||||
return eval_recurse(partial, exp, '$.{{value}}');
|
||||
},
|
||||
|
||||
'member-descendant-script_expression': function(component, partial) {
|
||||
var exp = component.expression.value.slice(1, -1);
|
||||
return eval_recurse(partial, exp, '$..value');
|
||||
}
|
||||
};
|
||||
|
||||
Handlers.prototype._fns['subscript-child-string_literal'] =
|
||||
Handlers.prototype._fns['member-child-identifier'];
|
||||
|
||||
Handlers.prototype._fns['member-descendant-numeric_literal'] =
|
||||
Handlers.prototype._fns['subscript-descendant-string_literal'] =
|
||||
Handlers.prototype._fns['member-descendant-identifier'];
|
||||
|
||||
function eval_recurse(partial, src, template) {
|
||||
|
||||
var jp = require('./index');
|
||||
var ast = aesprim.parse(src).body[0].expression;
|
||||
var value = evaluate(ast, { '@': partial.value });
|
||||
var path = template.replace(/\{\{\s*value\s*\}\}/g, value);
|
||||
|
||||
var results = jp.nodes(partial.value, path);
|
||||
results.forEach(function(r) {
|
||||
r.path = partial.path.concat(r.path.slice(1));
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function is_array(val) {
|
||||
return Array.isArray(val);
|
||||
}
|
||||
|
||||
function is_object(val) {
|
||||
// is this a non-array, non-null object?
|
||||
return val && !(val instanceof Array) && val instanceof Object;
|
||||
}
|
||||
|
||||
function traverser(recurse) {
|
||||
|
||||
return function(partial, ref, passable, count) {
|
||||
|
||||
var value = partial.value;
|
||||
var path = partial.path;
|
||||
|
||||
var results = [];
|
||||
|
||||
var descend = function(value, path) {
|
||||
|
||||
if (is_array(value)) {
|
||||
value.forEach(function(element, index) {
|
||||
if (results.length >= count) { return }
|
||||
if (passable(index, element, ref)) {
|
||||
results.push({ path: path.concat(index), value: element });
|
||||
}
|
||||
});
|
||||
value.forEach(function(element, index) {
|
||||
if (results.length >= count) { return }
|
||||
if (recurse) {
|
||||
descend(element, path.concat(index));
|
||||
}
|
||||
});
|
||||
} else if (is_object(value)) {
|
||||
this.keys(value).forEach(function(k) {
|
||||
if (results.length >= count) { return }
|
||||
if (passable(k, value[k], ref)) {
|
||||
results.push({ path: path.concat(k), value: value[k] });
|
||||
}
|
||||
})
|
||||
this.keys(value).forEach(function(k) {
|
||||
if (results.length >= count) { return }
|
||||
if (recurse) {
|
||||
descend(value[k], path.concat(k));
|
||||
}
|
||||
});
|
||||
}
|
||||
}.bind(this);
|
||||
descend(value, path);
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
function _descend(passable) {
|
||||
return function(component, partial, count) {
|
||||
return this.descend(partial, component.expression.value, passable, count);
|
||||
}
|
||||
}
|
||||
|
||||
function _traverse(passable) {
|
||||
return function(component, partial, count) {
|
||||
return this.traverse(partial, component.expression.value, passable, count);
|
||||
}
|
||||
}
|
||||
|
||||
function evaluate() {
|
||||
try { return _evaluate.apply(this, arguments) }
|
||||
catch (e) { }
|
||||
}
|
||||
|
||||
function unique(results) {
|
||||
results = results.filter(function(d) { return d })
|
||||
return _uniq(
|
||||
results,
|
||||
function(r) { return r.path.map(function(c) { return String(c).replace('-', '--') }).join('-') }
|
||||
);
|
||||
}
|
||||
|
||||
function _parse_nullable_int(val) {
|
||||
var sval = String(val);
|
||||
return sval.match(/^-?[0-9]+$/) ? parseInt(sval) : null;
|
||||
}
|
||||
|
||||
module.exports = Handlers;
|
249
node_modules/jsonpath/lib/index.js
generated
vendored
Normal file
249
node_modules/jsonpath/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,249 @@
|
||||
var assert = require('assert');
|
||||
var dict = require('./dict');
|
||||
var Parser = require('./parser');
|
||||
var Handlers = require('./handlers');
|
||||
|
||||
var JSONPath = function() {
|
||||
this.initialize.apply(this, arguments);
|
||||
};
|
||||
|
||||
JSONPath.prototype.initialize = function() {
|
||||
this.parser = new Parser();
|
||||
this.handlers = new Handlers();
|
||||
};
|
||||
|
||||
JSONPath.prototype.parse = function(string) {
|
||||
assert.ok(_is_string(string), "we need a path");
|
||||
return this.parser.parse(string);
|
||||
};
|
||||
|
||||
JSONPath.prototype.parent = function(obj, string) {
|
||||
|
||||
assert.ok(obj instanceof Object, "obj needs to be an object");
|
||||
assert.ok(string, "we need a path");
|
||||
|
||||
var node = this.nodes(obj, string)[0];
|
||||
var key = node.path.pop(); /* jshint unused:false */
|
||||
return this.value(obj, node.path);
|
||||
}
|
||||
|
||||
JSONPath.prototype.apply = function(obj, string, fn) {
|
||||
|
||||
assert.ok(obj instanceof Object, "obj needs to be an object");
|
||||
assert.ok(string, "we need a path");
|
||||
assert.equal(typeof fn, "function", "fn needs to be function")
|
||||
|
||||
var nodes = this.nodes(obj, string).sort(function(a, b) {
|
||||
// sort nodes so we apply from the bottom up
|
||||
return b.path.length - a.path.length;
|
||||
});
|
||||
|
||||
nodes.forEach(function(node) {
|
||||
var key = node.path.pop();
|
||||
var parent = this.value(obj, this.stringify(node.path));
|
||||
var val = node.value = fn.call(obj, parent[key]);
|
||||
parent[key] = val;
|
||||
}, this);
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
JSONPath.prototype.value = function(obj, path, value) {
|
||||
|
||||
assert.ok(obj instanceof Object, "obj needs to be an object");
|
||||
assert.ok(path, "we need a path");
|
||||
|
||||
if (arguments.length >= 3) {
|
||||
var node = this.nodes(obj, path).shift();
|
||||
if (!node) return this._vivify(obj, path, value);
|
||||
var key = node.path.slice(-1).shift();
|
||||
var parent = this.parent(obj, this.stringify(node.path));
|
||||
parent[key] = value;
|
||||
}
|
||||
return this.query(obj, this.stringify(path), 1).shift();
|
||||
}
|
||||
|
||||
JSONPath.prototype._vivify = function(obj, string, value) {
|
||||
|
||||
var self = this;
|
||||
|
||||
assert.ok(obj instanceof Object, "obj needs to be an object");
|
||||
assert.ok(string, "we need a path");
|
||||
|
||||
var path = this.parser.parse(string)
|
||||
.map(function(component) { return component.expression.value });
|
||||
|
||||
var setValue = function(path, value) {
|
||||
var key = path.pop();
|
||||
var node = self.value(obj, path);
|
||||
if (!node) {
|
||||
setValue(path.concat(), typeof key === 'string' ? {} : []);
|
||||
node = self.value(obj, path);
|
||||
}
|
||||
node[key] = value;
|
||||
}
|
||||
setValue(path, value);
|
||||
return this.query(obj, string)[0];
|
||||
}
|
||||
|
||||
JSONPath.prototype.query = function(obj, string, count) {
|
||||
|
||||
assert.ok(obj instanceof Object, "obj needs to be an object");
|
||||
assert.ok(_is_string(string), "we need a path");
|
||||
|
||||
var results = this.nodes(obj, string, count)
|
||||
.map(function(r) { return r.value });
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
JSONPath.prototype.paths = function(obj, string, count) {
|
||||
|
||||
assert.ok(obj instanceof Object, "obj needs to be an object");
|
||||
assert.ok(string, "we need a path");
|
||||
|
||||
var results = this.nodes(obj, string, count)
|
||||
.map(function(r) { return r.path });
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
JSONPath.prototype.nodes = function(obj, string, count) {
|
||||
|
||||
assert.ok(obj instanceof Object, "obj needs to be an object");
|
||||
assert.ok(string, "we need a path");
|
||||
|
||||
if (count === 0) return [];
|
||||
|
||||
var path = this.parser.parse(string);
|
||||
var handlers = this.handlers;
|
||||
|
||||
var partials = [ { path: ['$'], value: obj } ];
|
||||
var matches = [];
|
||||
|
||||
if (path.length && path[0].expression.type == 'root') path.shift();
|
||||
|
||||
if (!path.length) return partials;
|
||||
|
||||
path.forEach(function(component, index) {
|
||||
|
||||
if (matches.length >= count) return;
|
||||
var handler = handlers.resolve(component);
|
||||
var _partials = [];
|
||||
|
||||
partials.forEach(function(p) {
|
||||
|
||||
if (matches.length >= count) return;
|
||||
var results = handler(component, p, count);
|
||||
|
||||
if (index == path.length - 1) {
|
||||
// if we're through the components we're done
|
||||
matches = matches.concat(results || []);
|
||||
} else {
|
||||
// otherwise accumulate and carry on through
|
||||
_partials = _partials.concat(results || []);
|
||||
}
|
||||
});
|
||||
|
||||
partials = _partials;
|
||||
|
||||
});
|
||||
|
||||
return count ? matches.slice(0, count) : matches;
|
||||
};
|
||||
|
||||
JSONPath.prototype.stringify = function(path) {
|
||||
|
||||
assert.ok(path, "we need a path");
|
||||
|
||||
var string = '$';
|
||||
|
||||
var templates = {
|
||||
'descendant-member': '..{{value}}',
|
||||
'child-member': '.{{value}}',
|
||||
'descendant-subscript': '..[{{value}}]',
|
||||
'child-subscript': '[{{value}}]'
|
||||
};
|
||||
|
||||
path = this._normalize(path);
|
||||
|
||||
path.forEach(function(component) {
|
||||
|
||||
if (component.expression.type == 'root') return;
|
||||
|
||||
var key = [component.scope, component.operation].join('-');
|
||||
var template = templates[key];
|
||||
var value;
|
||||
|
||||
if (component.expression.type == 'string_literal') {
|
||||
value = JSON.stringify(component.expression.value)
|
||||
} else {
|
||||
value = component.expression.value;
|
||||
}
|
||||
|
||||
if (!template) throw new Error("couldn't find template " + key);
|
||||
|
||||
string += template.replace(/{{value}}/, value);
|
||||
});
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
JSONPath.prototype._normalize = function(path) {
|
||||
|
||||
assert.ok(path, "we need a path");
|
||||
|
||||
if (typeof path == "string") {
|
||||
|
||||
return this.parser.parse(path);
|
||||
|
||||
} else if (Array.isArray(path) && typeof path[0] == "string") {
|
||||
|
||||
var _path = [ { expression: { type: "root", value: "$" } } ];
|
||||
|
||||
path.forEach(function(component, index) {
|
||||
|
||||
if (component == '$' && index === 0) return;
|
||||
|
||||
if (typeof component == "string" && component.match("^" + dict.identifier + "$")) {
|
||||
|
||||
_path.push({
|
||||
operation: 'member',
|
||||
scope: 'child',
|
||||
expression: { value: component, type: 'identifier' }
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
var type = typeof component == "number" ?
|
||||
'numeric_literal' : 'string_literal';
|
||||
|
||||
_path.push({
|
||||
operation: 'subscript',
|
||||
scope: 'child',
|
||||
expression: { value: component, type: type }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return _path;
|
||||
|
||||
} else if (Array.isArray(path) && typeof path[0] == "object") {
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
throw new Error("couldn't understand path " + path);
|
||||
}
|
||||
|
||||
function _is_string(obj) {
|
||||
return Object.prototype.toString.call(obj) == '[object String]';
|
||||
}
|
||||
|
||||
JSONPath.Handlers = Handlers;
|
||||
JSONPath.Parser = Parser;
|
||||
|
||||
var instance = new JSONPath;
|
||||
instance.JSONPath = JSONPath;
|
||||
|
||||
module.exports = instance;
|
21
node_modules/jsonpath/lib/parser.js
generated
vendored
Normal file
21
node_modules/jsonpath/lib/parser.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
var grammar = require('./grammar');
|
||||
var gparser = require('../generated/parser');
|
||||
|
||||
var Parser = function() {
|
||||
|
||||
var parser = new gparser.Parser();
|
||||
|
||||
var _parseError = parser.parseError;
|
||||
parser.yy.parseError = function() {
|
||||
if (parser.yy.ast) {
|
||||
parser.yy.ast.initialize();
|
||||
}
|
||||
_parseError.apply(parser, arguments);
|
||||
}
|
||||
|
||||
return parser;
|
||||
|
||||
};
|
||||
|
||||
Parser.grammar = grammar;
|
||||
module.exports = Parser;
|
41
node_modules/jsonpath/lib/slice.js
generated
vendored
Normal file
41
node_modules/jsonpath/lib/slice.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
module.exports = function(arr, start, end, step) {
|
||||
|
||||
if (typeof start == 'string') throw new Error("start cannot be a string");
|
||||
if (typeof end == 'string') throw new Error("end cannot be a string");
|
||||
if (typeof step == 'string') throw new Error("step cannot be a string");
|
||||
|
||||
var len = arr.length;
|
||||
|
||||
if (step === 0) throw new Error("step cannot be zero");
|
||||
step = step ? integer(step) : 1;
|
||||
|
||||
// normalize negative values
|
||||
start = start < 0 ? len + start : start;
|
||||
end = end < 0 ? len + end : end;
|
||||
|
||||
// default extents to extents
|
||||
start = integer(start === 0 ? 0 : !start ? (step > 0 ? 0 : len - 1) : start);
|
||||
end = integer(end === 0 ? 0 : !end ? (step > 0 ? len : -1) : end);
|
||||
|
||||
// clamp extents
|
||||
start = step > 0 ? Math.max(0, start) : Math.min(len, start);
|
||||
end = step > 0 ? Math.min(end, len) : Math.max(-1, end);
|
||||
|
||||
// return empty if extents are backwards
|
||||
if (step > 0 && end <= start) return [];
|
||||
if (step < 0 && start <= end) return [];
|
||||
|
||||
var result = [];
|
||||
|
||||
for (var i = start; i != end; i += step) {
|
||||
if ((step < 0 && i <= end) || (step > 0 && i >= end)) break;
|
||||
result.push(arr[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function integer(val) {
|
||||
return String(val).match(/^[0-9]+$/) ? parseInt(val) :
|
||||
Number.isFinite(val) ? parseInt(val, 10) : 0;
|
||||
}
|
15
node_modules/jsonpath/node_modules/.bin/esparse
generated
vendored
Normal file
15
node_modules/jsonpath/node_modules/.bin/esparse
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../esprima/bin/esparse.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../esprima/bin/esparse.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
17
node_modules/jsonpath/node_modules/.bin/esparse.cmd
generated
vendored
Normal file
17
node_modules/jsonpath/node_modules/.bin/esparse.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\esprima\bin\esparse.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
18
node_modules/jsonpath/node_modules/.bin/esparse.ps1
generated
vendored
Normal file
18
node_modules/jsonpath/node_modules/.bin/esparse.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../esprima/bin/esparse.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../esprima/bin/esparse.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
15
node_modules/jsonpath/node_modules/.bin/esvalidate
generated
vendored
Normal file
15
node_modules/jsonpath/node_modules/.bin/esvalidate
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../esprima/bin/esvalidate.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../esprima/bin/esvalidate.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
17
node_modules/jsonpath/node_modules/.bin/esvalidate.cmd
generated
vendored
Normal file
17
node_modules/jsonpath/node_modules/.bin/esvalidate.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\esprima\bin\esvalidate.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
18
node_modules/jsonpath/node_modules/.bin/esvalidate.ps1
generated
vendored
Normal file
18
node_modules/jsonpath/node_modules/.bin/esvalidate.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../esprima/bin/esvalidate.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../esprima/bin/esvalidate.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
24
node_modules/jsonpath/node_modules/esprima/README.md
generated
vendored
Normal file
24
node_modules/jsonpath/node_modules/esprima/README.md
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
|
||||
standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||
parser written in ECMAScript (also popularly known as
|
||||
[JavaScript](http://en.wikipedia.org/wiki/JavaScript>JavaScript)).
|
||||
Esprima is created and maintained by [Ariya Hidayat](http://twitter.com/ariyahidayat),
|
||||
with the help of [many contributors](https://github.com/ariya/esprima/contributors).
|
||||
|
||||
### Features
|
||||
|
||||
- Full support for ECMAScript 5.1 ([ECMA-262](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
|
||||
- Sensible [syntax tree format](http://esprima.org/doc/index.html#ast) compatible with Mozilla
|
||||
[Parser AST](https://developer.mozilla.org/en/SpiderMonkey/Parser_API)
|
||||
- Optional tracking of syntax node location (index-based and line-column)
|
||||
- Heavily tested (> 650 [unit tests](http://esprima.org/test/) with [full code coverage](http://esprima.org/test/coverage.html))
|
||||
- [Partial support](http://esprima.org/doc/es6.html) for ECMAScript 6
|
||||
|
||||
Esprima serves as a **building block** for some JavaScript
|
||||
language tools, from [code instrumentation](http://esprima.org/demo/functiontrace.html)
|
||||
to [editor autocompletion](http://esprima.org/demo/autocomplete.html).
|
||||
|
||||
Esprima runs on many popular web browsers, as well as other ECMAScript platforms such as
|
||||
[Rhino](http://www.mozilla.org/rhino), [Nashorn](http://openjdk.java.net/projects/nashorn/), and [Node.js](https://npmjs.org/package/esprima).
|
||||
|
||||
For more information, check the web site [esprima.org](http://esprima.org).
|
3756
node_modules/jsonpath/node_modules/esprima/esprima.js
generated
vendored
Normal file
3756
node_modules/jsonpath/node_modules/esprima/esprima.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
107
node_modules/jsonpath/node_modules/esprima/package.json
generated
vendored
Normal file
107
node_modules/jsonpath/node_modules/esprima/package.json
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
{
|
||||
"_from": "esprima@1.2.2",
|
||||
"_id": "esprima@1.2.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=",
|
||||
"_location": "/jsonpath/esprima",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "esprima@1.2.2",
|
||||
"name": "esprima",
|
||||
"escapedName": "esprima",
|
||||
"rawSpec": "1.2.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.2.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jsonpath"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz",
|
||||
"_shasum": "76a0fd66fcfe154fd292667dc264019750b1657b",
|
||||
"_spec": "esprima@1.2.2",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules\\jsonpath",
|
||||
"author": {
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://issues.esprima.org"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "ECMAScript parsing infrastructure for multipurpose analysis",
|
||||
"devDependencies": {
|
||||
"complexity-report": "~0.6.1",
|
||||
"eslint": "~0.4.3",
|
||||
"istanbul": "~0.2.6",
|
||||
"jscs": "~1.2.4",
|
||||
"jslint": "~0.1.9",
|
||||
"json-diff": "~0.3.1",
|
||||
"optimist": "~0.6.0",
|
||||
"regenerate": "~0.5.4",
|
||||
"unicode-6.3.0": "~0.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"test/run.js",
|
||||
"test/runner.js",
|
||||
"test/test.js",
|
||||
"test/compat.js",
|
||||
"test/reflect.js",
|
||||
"esprima.js"
|
||||
],
|
||||
"homepage": "http://esprima.org",
|
||||
"keywords": [
|
||||
"ast",
|
||||
"ecmascript",
|
||||
"javascript",
|
||||
"parser",
|
||||
"syntax"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "BSD",
|
||||
"url": "http://github.com/ariya/esprima/raw/master/LICENSE.BSD"
|
||||
}
|
||||
],
|
||||
"main": "esprima.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com",
|
||||
"url": "http://ariya.ofilabs.com"
|
||||
}
|
||||
],
|
||||
"name": "esprima",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/ariya/esprima.git"
|
||||
},
|
||||
"scripts": {
|
||||
"analyze-complexity": "node tools/list-complexity.js",
|
||||
"analyze-coverage": "node node_modules/istanbul/lib/cli.js cover test/runner.js",
|
||||
"benchmark": "node test/benchmarks.js",
|
||||
"benchmark-quick": "node test/benchmarks.js quick",
|
||||
"check-complexity": "node node_modules/complexity-report/src/cli.js --maxcc 14 --silent -l -w esprima.js",
|
||||
"check-coverage": "node node_modules/istanbul/lib/cli.js check-coverage --statement 100 --branch 100 --function 100",
|
||||
"check-version": "node tools/check-version.js",
|
||||
"complexity": "npm run-script analyze-complexity && npm run-script check-complexity",
|
||||
"coverage": "npm run-script analyze-coverage && npm run-script check-coverage",
|
||||
"eslint": "node node_modules/eslint/bin/eslint.js esprima.js",
|
||||
"generate-regex": "node tools/generate-identifier-regex.js",
|
||||
"jscs": "node node_modules/.bin/jscs esprima.js",
|
||||
"jslint": "node node_modules/jslint/bin/jslint.js esprima.js",
|
||||
"lint": "npm run-script check-version && npm run-script eslint && npm run-script jscs && npm run-script jslint",
|
||||
"test": "npm run-script lint && node test/run.js && npm run-script coverage && npm run-script complexity"
|
||||
},
|
||||
"version": "1.2.2"
|
||||
}
|
241
node_modules/jsonpath/node_modules/esprima/test/compat.js
generated
vendored
Normal file
241
node_modules/jsonpath/node_modules/esprima/test/compat.js
generated
vendored
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
|
||||
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint node: true */
|
||||
/*global document: true, window:true, esprima: true, testReflect: true */
|
||||
|
||||
var runTests;
|
||||
|
||||
function getContext(esprima, reportCase, reportFailure) {
|
||||
'use strict';
|
||||
|
||||
var Reflect, Pattern;
|
||||
|
||||
// Maps Mozilla Reflect object to our Esprima parser.
|
||||
Reflect = {
|
||||
parse: function (code) {
|
||||
var result;
|
||||
|
||||
reportCase(code);
|
||||
|
||||
try {
|
||||
result = esprima.parse(code);
|
||||
} catch (error) {
|
||||
result = error;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// This is used by Reflect test suite to match a syntax tree.
|
||||
Pattern = function (obj) {
|
||||
var pattern;
|
||||
|
||||
// Poor man's deep object cloning.
|
||||
pattern = JSON.parse(JSON.stringify(obj));
|
||||
|
||||
// Special handling for regular expression literal since we need to
|
||||
// convert it to a string literal, otherwise it will be decoded
|
||||
// as object "{}" and the regular expression would be lost.
|
||||
if (obj.type && obj.type === 'Literal') {
|
||||
if (obj.value instanceof RegExp) {
|
||||
pattern = {
|
||||
type: obj.type,
|
||||
value: obj.value.toString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling for branch statement because SpiderMonkey
|
||||
// prefers to put the 'alternate' property before 'consequent'.
|
||||
if (obj.type && obj.type === 'IfStatement') {
|
||||
pattern = {
|
||||
type: pattern.type,
|
||||
test: pattern.test,
|
||||
consequent: pattern.consequent,
|
||||
alternate: pattern.alternate
|
||||
};
|
||||
}
|
||||
|
||||
// Special handling for do while statement because SpiderMonkey
|
||||
// prefers to put the 'test' property before 'body'.
|
||||
if (obj.type && obj.type === 'DoWhileStatement') {
|
||||
pattern = {
|
||||
type: pattern.type,
|
||||
body: pattern.body,
|
||||
test: pattern.test
|
||||
};
|
||||
}
|
||||
|
||||
function adjustRegexLiteralAndRaw(key, value) {
|
||||
if (key === 'value' && value instanceof RegExp) {
|
||||
value = value.toString();
|
||||
} else if (key === 'raw' && typeof value === "string") {
|
||||
// Ignore Esprima-specific 'raw' property.
|
||||
return undefined;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
if (obj.type && (obj.type === 'Program')) {
|
||||
pattern.assert = function (tree) {
|
||||
var actual, expected;
|
||||
actual = JSON.stringify(tree, adjustRegexLiteralAndRaw, 4);
|
||||
expected = JSON.stringify(obj, null, 4);
|
||||
|
||||
if (expected !== actual) {
|
||||
reportFailure(expected, actual);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return pattern;
|
||||
};
|
||||
|
||||
return {
|
||||
Reflect: Reflect,
|
||||
Pattern: Pattern
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
// Run all tests in a browser environment.
|
||||
runTests = function () {
|
||||
'use strict';
|
||||
|
||||
var total = 0,
|
||||
failures = 0;
|
||||
|
||||
function setText(el, str) {
|
||||
if (typeof el.innerText === 'string') {
|
||||
el.innerText = str;
|
||||
} else {
|
||||
el.textContent = str;
|
||||
}
|
||||
}
|
||||
|
||||
function reportCase(code) {
|
||||
var report, e;
|
||||
report = document.getElementById('report');
|
||||
e = document.createElement('pre');
|
||||
e.setAttribute('class', 'code');
|
||||
setText(e, code);
|
||||
report.appendChild(e);
|
||||
total += 1;
|
||||
}
|
||||
|
||||
function reportFailure(expected, actual) {
|
||||
var report, e;
|
||||
|
||||
failures += 1;
|
||||
|
||||
report = document.getElementById('report');
|
||||
|
||||
e = document.createElement('p');
|
||||
setText(e, 'Expected');
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('pre');
|
||||
e.setAttribute('class', 'expected');
|
||||
setText(e, expected);
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('p');
|
||||
setText(e, 'Actual');
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('pre');
|
||||
e.setAttribute('class', 'actual');
|
||||
setText(e, actual);
|
||||
report.appendChild(e);
|
||||
}
|
||||
|
||||
setText(document.getElementById('version'), esprima.version);
|
||||
|
||||
window.setTimeout(function () {
|
||||
var tick, context = getContext(esprima, reportCase, reportFailure);
|
||||
|
||||
tick = new Date();
|
||||
testReflect(context.Reflect, context.Pattern);
|
||||
tick = (new Date()) - tick;
|
||||
|
||||
if (failures > 0) {
|
||||
document.getElementById('status').className = 'alert-box alert';
|
||||
setText(document.getElementById('status'), total + ' tests. ' +
|
||||
'Failures: ' + failures + '. ' + tick + ' ms');
|
||||
} else {
|
||||
document.getElementById('status').className = 'alert-box success';
|
||||
setText(document.getElementById('status'), total + ' tests. ' +
|
||||
'No failure. ' + tick + ' ms');
|
||||
}
|
||||
}, 11);
|
||||
};
|
||||
} else {
|
||||
(function (global) {
|
||||
'use strict';
|
||||
var esprima = require('../esprima'),
|
||||
tick,
|
||||
total = 0,
|
||||
failures = [],
|
||||
header,
|
||||
current,
|
||||
context;
|
||||
|
||||
function reportCase(code) {
|
||||
total += 1;
|
||||
current = code;
|
||||
}
|
||||
|
||||
function reportFailure(expected, actual) {
|
||||
failures.push({
|
||||
source: current,
|
||||
expected: expected.toString(),
|
||||
actual: actual.toString()
|
||||
});
|
||||
}
|
||||
|
||||
context = getContext(esprima, reportCase, reportFailure);
|
||||
|
||||
tick = new Date();
|
||||
require('./reflect').testReflect(context.Reflect, context.Pattern);
|
||||
tick = (new Date()) - tick;
|
||||
|
||||
header = total + ' tests. ' + failures.length + ' failures. ' +
|
||||
tick + ' ms';
|
||||
if (failures.length) {
|
||||
console.error(header);
|
||||
failures.forEach(function (failure) {
|
||||
console.error(failure.source + ': Expected\n ' +
|
||||
failure.expected.split('\n').join('\n ') +
|
||||
'\nto match\n ' + failure.actual);
|
||||
});
|
||||
} else {
|
||||
console.log(header);
|
||||
}
|
||||
process.exit(failures.length === 0 ? 0 : 1);
|
||||
}(this));
|
||||
}
|
||||
/* vim: set sw=4 ts=4 et tw=80 : */
|
422
node_modules/jsonpath/node_modules/esprima/test/reflect.js
generated
vendored
Normal file
422
node_modules/jsonpath/node_modules/esprima/test/reflect.js
generated
vendored
Normal file
@ -0,0 +1,422 @@
|
||||
// This is modified from Mozilla Reflect.parse test suite (the file is located
|
||||
// at js/src/tests/js1_8_5/extensions/reflect-parse.js in the source tree).
|
||||
//
|
||||
// Some notable changes:
|
||||
// * Removed unsupported features (destructuring, let, comprehensions...).
|
||||
// * Removed tests for E4X (ECMAScript for XML).
|
||||
// * Removed everything related to builder.
|
||||
// * Enclosed every 'Pattern' construct with a scope.
|
||||
// * Tweaked some expected tree to remove generator field.
|
||||
// * Removed the test for bug 632030 and bug 632024.
|
||||
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
(function (exports) {
|
||||
|
||||
function testReflect(Reflect, Pattern) {
|
||||
|
||||
function program(elts) { return Pattern({ type: "Program", body: elts }) }
|
||||
function exprStmt(expr) { return Pattern({ type: "ExpressionStatement", expression: expr }) }
|
||||
function throwStmt(expr) { return Pattern({ type: "ThrowStatement", argument: expr }) }
|
||||
function returnStmt(expr) { return Pattern({ type: "ReturnStatement", argument: expr }) }
|
||||
function yieldExpr(expr) { return Pattern({ type: "YieldExpression", argument: expr }) }
|
||||
function lit(val) { return Pattern({ type: "Literal", value: val }) }
|
||||
var thisExpr = Pattern({ type: "ThisExpression" });
|
||||
function funDecl(id, params, body) { return Pattern({ type: "FunctionDeclaration",
|
||||
id: id,
|
||||
params: params,
|
||||
defaults: [],
|
||||
body: body,
|
||||
rest: null,
|
||||
generator: false,
|
||||
expression: false
|
||||
}) }
|
||||
function genFunDecl(id, params, body) { return Pattern({ type: "FunctionDeclaration",
|
||||
id: id,
|
||||
params: params,
|
||||
defaults: [],
|
||||
body: body,
|
||||
rest: null,
|
||||
generator: false,
|
||||
expression: false
|
||||
}) }
|
||||
function declarator(id, init) { return Pattern({ type: "VariableDeclarator", id: id, init: init }) }
|
||||
function varDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "var" }) }
|
||||
function letDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "let" }) }
|
||||
function constDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "const" }) }
|
||||
function ident(name) { return Pattern({ type: "Identifier", name: name }) }
|
||||
function dotExpr(obj, id) { return Pattern({ type: "MemberExpression", computed: false, object: obj, property: id }) }
|
||||
function memExpr(obj, id) { return Pattern({ type: "MemberExpression", computed: true, object: obj, property: id }) }
|
||||
function forStmt(init, test, update, body) { return Pattern({ type: "ForStatement", init: init, test: test, update: update, body: body }) }
|
||||
function forInStmt(lhs, rhs, body) { return Pattern({ type: "ForInStatement", left: lhs, right: rhs, body: body, each: false }) }
|
||||
function forEachInStmt(lhs, rhs, body) { return Pattern({ type: "ForInStatement", left: lhs, right: rhs, body: body, each: true }) }
|
||||
function breakStmt(lab) { return Pattern({ type: "BreakStatement", label: lab }) }
|
||||
function continueStmt(lab) { return Pattern({ type: "ContinueStatement", label: lab }) }
|
||||
function blockStmt(body) { return Pattern({ type: "BlockStatement", body: body }) }
|
||||
var emptyStmt = Pattern({ type: "EmptyStatement" });
|
||||
function ifStmt(test, cons, alt) { return Pattern({ type: "IfStatement", test: test, alternate: alt, consequent: cons }) }
|
||||
function labStmt(lab, stmt) { return Pattern({ type: "LabeledStatement", label: lab, body: stmt }) }
|
||||
function withStmt(obj, stmt) { return Pattern({ type: "WithStatement", object: obj, body: stmt }) }
|
||||
function whileStmt(test, stmt) { return Pattern({ type: "WhileStatement", test: test, body: stmt }) }
|
||||
function doStmt(stmt, test) { return Pattern({ type: "DoWhileStatement", test: test, body: stmt }) }
|
||||
function switchStmt(disc, cases) { return Pattern({ type: "SwitchStatement", discriminant: disc, cases: cases }) }
|
||||
function caseClause(test, stmts) { return Pattern({ type: "SwitchCase", test: test, consequent: stmts }) }
|
||||
function defaultClause(stmts) { return Pattern({ type: "SwitchCase", test: null, consequent: stmts }) }
|
||||
function catchClause(id, guard, body) { if (guard) { return Pattern({ type: "GuardedCatchClause", param: id, guard: guard, body: body }) } else { return Pattern({ type: "CatchClause", param: id, body: body }) } }
|
||||
function tryStmt(body, guarded, catches, fin) { return Pattern({ type: "TryStatement", block: body, guardedHandlers: guarded, handlers: catches, finalizer: fin }) }
|
||||
function letStmt(head, body) { return Pattern({ type: "LetStatement", head: head, body: body }) }
|
||||
function funExpr(id, args, body, gen) { return Pattern({ type: "FunctionExpression",
|
||||
id: id,
|
||||
params: args,
|
||||
defaults: [],
|
||||
body: body,
|
||||
rest: null,
|
||||
generator: false,
|
||||
expression: false
|
||||
}) }
|
||||
function genFunExpr(id, args, body) { return Pattern({ type: "FunctionExpression",
|
||||
id: id,
|
||||
params: args,
|
||||
defaults: [],
|
||||
body: body,
|
||||
rest: null,
|
||||
generator: false,
|
||||
expression: false
|
||||
}) }
|
||||
|
||||
function unExpr(op, arg) { return Pattern({ type: "UnaryExpression", operator: op, argument: arg, prefix: true }) }
|
||||
function binExpr(op, left, right) { return Pattern({ type: "BinaryExpression", operator: op, left: left, right: right }) }
|
||||
function aExpr(op, left, right) { return Pattern({ type: "AssignmentExpression", operator: op, left: left, right: right }) }
|
||||
function updExpr(op, arg, prefix) { return Pattern({ type: "UpdateExpression", operator: op, argument: arg, prefix: prefix }) }
|
||||
function logExpr(op, left, right) { return Pattern({ type: "LogicalExpression", operator: op, left: left, right: right }) }
|
||||
|
||||
function condExpr(test, cons, alt) { return Pattern({ type: "ConditionalExpression", test: test, consequent: cons, alternate: alt }) }
|
||||
function seqExpr(exprs) { return Pattern({ type: "SequenceExpression", expressions: exprs }) }
|
||||
function newExpr(callee, args) { return Pattern({ type: "NewExpression", callee: callee, arguments: args }) }
|
||||
function callExpr(callee, args) { return Pattern({ type: "CallExpression", callee: callee, arguments: args }) }
|
||||
function arrExpr(elts) { return Pattern({ type: "ArrayExpression", elements: elts }) }
|
||||
function objExpr(elts) { return Pattern({ type: "ObjectExpression", properties: elts }) }
|
||||
function objProp(key, value, kind) { return Pattern({ type: "Property", key: key, value: value, kind: kind }) }
|
||||
|
||||
function arrPatt(elts) { return Pattern({ type: "ArrayPattern", elements: elts }) }
|
||||
function objPatt(elts) { return Pattern({ type: "ObjectPattern", properties: elts }) }
|
||||
|
||||
function localSrc(src) { return "(function(){ " + src + " })" }
|
||||
function localPatt(patt) { return program([exprStmt(funExpr(null, [], blockStmt([patt])))]) }
|
||||
function blockSrc(src) { return "(function(){ { " + src + " } })" }
|
||||
function blockPatt(patt) { return program([exprStmt(funExpr(null, [], blockStmt([blockStmt([patt])])))]) }
|
||||
|
||||
function assertBlockStmt(src, patt) {
|
||||
blockPatt(patt).assert(Reflect.parse(blockSrc(src)));
|
||||
}
|
||||
|
||||
function assertBlockExpr(src, patt) {
|
||||
assertBlockStmt(src, exprStmt(patt));
|
||||
}
|
||||
|
||||
function assertBlockDecl(src, patt, builder) {
|
||||
blockPatt(patt).assert(Reflect.parse(blockSrc(src), {builder: builder}));
|
||||
}
|
||||
|
||||
function assertLocalStmt(src, patt) {
|
||||
localPatt(patt).assert(Reflect.parse(localSrc(src)));
|
||||
}
|
||||
|
||||
function assertLocalExpr(src, patt) {
|
||||
assertLocalStmt(src, exprStmt(patt));
|
||||
}
|
||||
|
||||
function assertLocalDecl(src, patt) {
|
||||
localPatt(patt).assert(Reflect.parse(localSrc(src)));
|
||||
}
|
||||
|
||||
function assertGlobalStmt(src, patt, builder) {
|
||||
program([patt]).assert(Reflect.parse(src, {builder: builder}));
|
||||
}
|
||||
|
||||
function assertGlobalExpr(src, patt, builder) {
|
||||
program([exprStmt(patt)]).assert(Reflect.parse(src, {builder: builder}));
|
||||
//assertStmt(src, exprStmt(patt));
|
||||
}
|
||||
|
||||
function assertGlobalDecl(src, patt) {
|
||||
program([patt]).assert(Reflect.parse(src));
|
||||
}
|
||||
|
||||
function assertProg(src, patt) {
|
||||
program(patt).assert(Reflect.parse(src));
|
||||
}
|
||||
|
||||
function assertStmt(src, patt) {
|
||||
assertLocalStmt(src, patt);
|
||||
assertGlobalStmt(src, patt);
|
||||
assertBlockStmt(src, patt);
|
||||
}
|
||||
|
||||
function assertExpr(src, patt) {
|
||||
assertLocalExpr(src, patt);
|
||||
assertGlobalExpr(src, patt);
|
||||
assertBlockExpr(src, patt);
|
||||
}
|
||||
|
||||
function assertDecl(src, patt) {
|
||||
assertLocalDecl(src, patt);
|
||||
assertGlobalDecl(src, patt);
|
||||
assertBlockDecl(src, patt);
|
||||
}
|
||||
|
||||
function assertError(src, errorType) {
|
||||
try {
|
||||
Reflect.parse(src);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
throw new Error("expected " + errorType.name + " for " + uneval(src));
|
||||
}
|
||||
|
||||
|
||||
// general tests
|
||||
|
||||
// NB: These are useful but for now jit-test doesn't do I/O reliably.
|
||||
|
||||
//program(_).assert(Reflect.parse(snarf('data/flapjax.txt')));
|
||||
//program(_).assert(Reflect.parse(snarf('data/jquery-1.4.2.txt')));
|
||||
//program(_).assert(Reflect.parse(snarf('data/prototype.js')));
|
||||
//program(_).assert(Reflect.parse(snarf('data/dojo.js.uncompressed.js')));
|
||||
//program(_).assert(Reflect.parse(snarf('data/mootools-1.2.4-core-nc.js')));
|
||||
|
||||
|
||||
// declarations
|
||||
|
||||
assertDecl("var x = 1, y = 2, z = 3",
|
||||
varDecl([declarator(ident("x"), lit(1)),
|
||||
declarator(ident("y"), lit(2)),
|
||||
declarator(ident("z"), lit(3))]));
|
||||
assertDecl("var x, y, z",
|
||||
varDecl([declarator(ident("x"), null),
|
||||
declarator(ident("y"), null),
|
||||
declarator(ident("z"), null)]));
|
||||
assertDecl("function foo() { }",
|
||||
funDecl(ident("foo"), [], blockStmt([])));
|
||||
assertDecl("function foo() { return 42 }",
|
||||
funDecl(ident("foo"), [], blockStmt([returnStmt(lit(42))])));
|
||||
|
||||
|
||||
// Bug 591437: rebound args have their defs turned into uses
|
||||
assertDecl("function f(a) { function a() { } }",
|
||||
funDecl(ident("f"), [ident("a")], blockStmt([funDecl(ident("a"), [], blockStmt([]))])));
|
||||
assertDecl("function f(a,b,c) { function b() { } }",
|
||||
funDecl(ident("f"), [ident("a"),ident("b"),ident("c")], blockStmt([funDecl(ident("b"), [], blockStmt([]))])));
|
||||
|
||||
// expressions
|
||||
|
||||
assertExpr("true", lit(true));
|
||||
assertExpr("false", lit(false));
|
||||
assertExpr("42", lit(42));
|
||||
assertExpr("(/asdf/)", lit(/asdf/));
|
||||
assertExpr("this", thisExpr);
|
||||
assertExpr("foo", ident("foo"));
|
||||
assertExpr("foo.bar", dotExpr(ident("foo"), ident("bar")));
|
||||
assertExpr("foo[bar]", memExpr(ident("foo"), ident("bar")));
|
||||
assertExpr("(function(){})", funExpr(null, [], blockStmt([])));
|
||||
assertExpr("(function f() {})", funExpr(ident("f"), [], blockStmt([])));
|
||||
assertExpr("(function f(x,y,z) {})", funExpr(ident("f"), [ident("x"),ident("y"),ident("z")], blockStmt([])));
|
||||
assertExpr("(++x)", updExpr("++", ident("x"), true));
|
||||
assertExpr("(x++)", updExpr("++", ident("x"), false));
|
||||
assertExpr("(+x)", unExpr("+", ident("x")));
|
||||
assertExpr("(-x)", unExpr("-", ident("x")));
|
||||
assertExpr("(!x)", unExpr("!", ident("x")));
|
||||
assertExpr("(~x)", unExpr("~", ident("x")));
|
||||
assertExpr("(delete x)", unExpr("delete", ident("x")));
|
||||
assertExpr("(typeof x)", unExpr("typeof", ident("x")));
|
||||
assertExpr("(void x)", unExpr("void", ident("x")));
|
||||
assertExpr("(x == y)", binExpr("==", ident("x"), ident("y")));
|
||||
assertExpr("(x != y)", binExpr("!=", ident("x"), ident("y")));
|
||||
assertExpr("(x === y)", binExpr("===", ident("x"), ident("y")));
|
||||
assertExpr("(x !== y)", binExpr("!==", ident("x"), ident("y")));
|
||||
assertExpr("(x < y)", binExpr("<", ident("x"), ident("y")));
|
||||
assertExpr("(x <= y)", binExpr("<=", ident("x"), ident("y")));
|
||||
assertExpr("(x > y)", binExpr(">", ident("x"), ident("y")));
|
||||
assertExpr("(x >= y)", binExpr(">=", ident("x"), ident("y")));
|
||||
assertExpr("(x << y)", binExpr("<<", ident("x"), ident("y")));
|
||||
assertExpr("(x >> y)", binExpr(">>", ident("x"), ident("y")));
|
||||
assertExpr("(x >>> y)", binExpr(">>>", ident("x"), ident("y")));
|
||||
assertExpr("(x + y)", binExpr("+", ident("x"), ident("y")));
|
||||
assertExpr("(w + x + y + z)", binExpr("+", binExpr("+", binExpr("+", ident("w"), ident("x")), ident("y")), ident("z")));
|
||||
assertExpr("(x - y)", binExpr("-", ident("x"), ident("y")));
|
||||
assertExpr("(w - x - y - z)", binExpr("-", binExpr("-", binExpr("-", ident("w"), ident("x")), ident("y")), ident("z")));
|
||||
assertExpr("(x * y)", binExpr("*", ident("x"), ident("y")));
|
||||
assertExpr("(x / y)", binExpr("/", ident("x"), ident("y")));
|
||||
assertExpr("(x % y)", binExpr("%", ident("x"), ident("y")));
|
||||
assertExpr("(x | y)", binExpr("|", ident("x"), ident("y")));
|
||||
assertExpr("(x ^ y)", binExpr("^", ident("x"), ident("y")));
|
||||
assertExpr("(x & y)", binExpr("&", ident("x"), ident("y")));
|
||||
assertExpr("(x in y)", binExpr("in", ident("x"), ident("y")));
|
||||
assertExpr("(x instanceof y)", binExpr("instanceof", ident("x"), ident("y")));
|
||||
assertExpr("(x = y)", aExpr("=", ident("x"), ident("y")));
|
||||
assertExpr("(x += y)", aExpr("+=", ident("x"), ident("y")));
|
||||
assertExpr("(x -= y)", aExpr("-=", ident("x"), ident("y")));
|
||||
assertExpr("(x *= y)", aExpr("*=", ident("x"), ident("y")));
|
||||
assertExpr("(x /= y)", aExpr("/=", ident("x"), ident("y")));
|
||||
assertExpr("(x %= y)", aExpr("%=", ident("x"), ident("y")));
|
||||
assertExpr("(x <<= y)", aExpr("<<=", ident("x"), ident("y")));
|
||||
assertExpr("(x >>= y)", aExpr(">>=", ident("x"), ident("y")));
|
||||
assertExpr("(x >>>= y)", aExpr(">>>=", ident("x"), ident("y")));
|
||||
assertExpr("(x |= y)", aExpr("|=", ident("x"), ident("y")));
|
||||
assertExpr("(x ^= y)", aExpr("^=", ident("x"), ident("y")));
|
||||
assertExpr("(x &= y)", aExpr("&=", ident("x"), ident("y")));
|
||||
assertExpr("(x || y)", logExpr("||", ident("x"), ident("y")));
|
||||
assertExpr("(x && y)", logExpr("&&", ident("x"), ident("y")));
|
||||
assertExpr("(w || x || y || z)", logExpr("||", logExpr("||", logExpr("||", ident("w"), ident("x")), ident("y")), ident("z")))
|
||||
assertExpr("(x ? y : z)", condExpr(ident("x"), ident("y"), ident("z")));
|
||||
assertExpr("(x,y)", seqExpr([ident("x"),ident("y")]))
|
||||
assertExpr("(x,y,z)", seqExpr([ident("x"),ident("y"),ident("z")]))
|
||||
assertExpr("(a,b,c,d,e,f,g)", seqExpr([ident("a"),ident("b"),ident("c"),ident("d"),ident("e"),ident("f"),ident("g")]));
|
||||
assertExpr("(new Object)", newExpr(ident("Object"), []));
|
||||
assertExpr("(new Object())", newExpr(ident("Object"), []));
|
||||
assertExpr("(new Object(42))", newExpr(ident("Object"), [lit(42)]));
|
||||
assertExpr("(new Object(1,2,3))", newExpr(ident("Object"), [lit(1),lit(2),lit(3)]));
|
||||
assertExpr("(String())", callExpr(ident("String"), []));
|
||||
assertExpr("(String(42))", callExpr(ident("String"), [lit(42)]));
|
||||
assertExpr("(String(1,2,3))", callExpr(ident("String"), [lit(1),lit(2),lit(3)]));
|
||||
assertExpr("[]", arrExpr([]));
|
||||
assertExpr("[1]", arrExpr([lit(1)]));
|
||||
assertExpr("[1,2]", arrExpr([lit(1),lit(2)]));
|
||||
assertExpr("[1,2,3]", arrExpr([lit(1),lit(2),lit(3)]));
|
||||
assertExpr("[1,,2,3]", arrExpr([lit(1),,lit(2),lit(3)]));
|
||||
assertExpr("[1,,,2,3]", arrExpr([lit(1),,,lit(2),lit(3)]));
|
||||
assertExpr("[1,,,2,,3]", arrExpr([lit(1),,,lit(2),,lit(3)]));
|
||||
assertExpr("[1,,,2,,,3]", arrExpr([lit(1),,,lit(2),,,lit(3)]));
|
||||
assertExpr("[,1,2,3]", arrExpr([,lit(1),lit(2),lit(3)]));
|
||||
assertExpr("[,,1,2,3]", arrExpr([,,lit(1),lit(2),lit(3)]));
|
||||
assertExpr("[,,,1,2,3]", arrExpr([,,,lit(1),lit(2),lit(3)]));
|
||||
assertExpr("[,,,1,2,3,]", arrExpr([,,,lit(1),lit(2),lit(3)]));
|
||||
assertExpr("[,,,1,2,3,,]", arrExpr([,,,lit(1),lit(2),lit(3),undefined]));
|
||||
assertExpr("[,,,1,2,3,,,]", arrExpr([,,,lit(1),lit(2),lit(3),undefined,undefined]));
|
||||
assertExpr("[,,,,,]", arrExpr([undefined,undefined,undefined,undefined,undefined]));
|
||||
assertExpr("({})", objExpr([]));
|
||||
assertExpr("({x:1})", objExpr([objProp(ident("x"), lit(1), "init")]));
|
||||
assertExpr("({x:1, y:2})", objExpr([objProp(ident("x"), lit(1), "init"),
|
||||
objProp(ident("y"), lit(2), "init")]));
|
||||
assertExpr("({x:1, y:2, z:3})", objExpr([objProp(ident("x"), lit(1), "init"),
|
||||
objProp(ident("y"), lit(2), "init"),
|
||||
objProp(ident("z"), lit(3), "init") ]));
|
||||
assertExpr("({x:1, 'y':2, z:3})", objExpr([objProp(ident("x"), lit(1), "init"),
|
||||
objProp(lit("y"), lit(2), "init"),
|
||||
objProp(ident("z"), lit(3), "init") ]));
|
||||
assertExpr("({'x':1, 'y':2, z:3})", objExpr([objProp(lit("x"), lit(1), "init"),
|
||||
objProp(lit("y"), lit(2), "init"),
|
||||
objProp(ident("z"), lit(3), "init") ]));
|
||||
assertExpr("({'x':1, 'y':2, 3:3})", objExpr([objProp(lit("x"), lit(1), "init"),
|
||||
objProp(lit("y"), lit(2), "init"),
|
||||
objProp(lit(3), lit(3), "init") ]));
|
||||
|
||||
// Bug 571617: eliminate constant-folding
|
||||
assertExpr("2 + 3", binExpr("+", lit(2), lit(3)));
|
||||
|
||||
// Bug 632026: constant-folding
|
||||
assertExpr("typeof(0?0:a)", unExpr("typeof", condExpr(lit(0), lit(0), ident("a"))));
|
||||
|
||||
// Bug 632056: constant-folding
|
||||
program([exprStmt(ident("f")),
|
||||
ifStmt(lit(1),
|
||||
funDecl(ident("f"), [], blockStmt([])),
|
||||
null)]).assert(Reflect.parse("f; if (1) function f(){}"));
|
||||
|
||||
// statements
|
||||
|
||||
assertStmt("throw 42", throwStmt(lit(42)));
|
||||
assertStmt("for (;;) break", forStmt(null, null, null, breakStmt(null)));
|
||||
assertStmt("for (x; y; z) break", forStmt(ident("x"), ident("y"), ident("z"), breakStmt(null)));
|
||||
assertStmt("for (var x; y; z) break", forStmt(varDecl([declarator(ident("x"), null)]), ident("y"), ident("z"), breakStmt(null)));
|
||||
assertStmt("for (var x = 42; y; z) break", forStmt(varDecl([declarator(ident("x"), lit(42))]), ident("y"), ident("z"), breakStmt(null)));
|
||||
assertStmt("for (x; ; z) break", forStmt(ident("x"), null, ident("z"), breakStmt(null)));
|
||||
assertStmt("for (var x; ; z) break", forStmt(varDecl([declarator(ident("x"), null)]), null, ident("z"), breakStmt(null)));
|
||||
assertStmt("for (var x = 42; ; z) break", forStmt(varDecl([declarator(ident("x"), lit(42))]), null, ident("z"), breakStmt(null)));
|
||||
assertStmt("for (x; y; ) break", forStmt(ident("x"), ident("y"), null, breakStmt(null)));
|
||||
assertStmt("for (var x; y; ) break", forStmt(varDecl([declarator(ident("x"), null)]), ident("y"), null, breakStmt(null)));
|
||||
assertStmt("for (var x = 42; y; ) break", forStmt(varDecl([declarator(ident("x"),lit(42))]), ident("y"), null, breakStmt(null)));
|
||||
assertStmt("for (var x in y) break", forInStmt(varDecl([declarator(ident("x"),null)]), ident("y"), breakStmt(null)));
|
||||
assertStmt("for (x in y) break", forInStmt(ident("x"), ident("y"), breakStmt(null)));
|
||||
assertStmt("{ }", blockStmt([]));
|
||||
assertStmt("{ throw 1; throw 2; throw 3; }", blockStmt([ throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]));
|
||||
assertStmt(";", emptyStmt);
|
||||
assertStmt("if (foo) throw 42;", ifStmt(ident("foo"), throwStmt(lit(42)), null));
|
||||
assertStmt("if (foo) throw 42; else true;", ifStmt(ident("foo"), throwStmt(lit(42)), exprStmt(lit(true))));
|
||||
assertStmt("if (foo) { throw 1; throw 2; throw 3; }",
|
||||
ifStmt(ident("foo"),
|
||||
blockStmt([throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]),
|
||||
null));
|
||||
assertStmt("if (foo) { throw 1; throw 2; throw 3; } else true;",
|
||||
ifStmt(ident("foo"),
|
||||
blockStmt([throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]),
|
||||
exprStmt(lit(true))));
|
||||
assertStmt("foo: for(;;) break foo;", labStmt(ident("foo"), forStmt(null, null, null, breakStmt(ident("foo")))));
|
||||
assertStmt("foo: for(;;) continue foo;", labStmt(ident("foo"), forStmt(null, null, null, continueStmt(ident("foo")))));
|
||||
assertStmt("with (obj) { }", withStmt(ident("obj"), blockStmt([])));
|
||||
assertStmt("with (obj) { obj; }", withStmt(ident("obj"), blockStmt([exprStmt(ident("obj"))])));
|
||||
assertStmt("while (foo) { }", whileStmt(ident("foo"), blockStmt([])));
|
||||
assertStmt("while (foo) { foo; }", whileStmt(ident("foo"), blockStmt([exprStmt(ident("foo"))])));
|
||||
assertStmt("do { } while (foo);", doStmt(blockStmt([]), ident("foo")));
|
||||
assertStmt("do { foo; } while (foo)", doStmt(blockStmt([exprStmt(ident("foo"))]), ident("foo")));
|
||||
assertStmt("switch (foo) { case 1: 1; break; case 2: 2; break; default: 3; }",
|
||||
switchStmt(ident("foo"),
|
||||
[ caseClause(lit(1), [ exprStmt(lit(1)), breakStmt(null) ]),
|
||||
caseClause(lit(2), [ exprStmt(lit(2)), breakStmt(null) ]),
|
||||
defaultClause([ exprStmt(lit(3)) ]) ]));
|
||||
assertStmt("switch (foo) { case 1: 1; break; case 2: 2; break; default: 3; case 42: 42; }",
|
||||
switchStmt(ident("foo"),
|
||||
[ caseClause(lit(1), [ exprStmt(lit(1)), breakStmt(null) ]),
|
||||
caseClause(lit(2), [ exprStmt(lit(2)), breakStmt(null) ]),
|
||||
defaultClause([ exprStmt(lit(3)) ]),
|
||||
caseClause(lit(42), [ exprStmt(lit(42)) ]) ]));
|
||||
assertStmt("try { } catch (e) { }",
|
||||
tryStmt(blockStmt([]),
|
||||
[],
|
||||
[ catchClause(ident("e"), null, blockStmt([])) ],
|
||||
null));
|
||||
assertStmt("try { } catch (e) { } finally { }",
|
||||
tryStmt(blockStmt([]),
|
||||
[],
|
||||
[ catchClause(ident("e"), null, blockStmt([])) ],
|
||||
blockStmt([])));
|
||||
assertStmt("try { } finally { }",
|
||||
tryStmt(blockStmt([]),
|
||||
[],
|
||||
[],
|
||||
blockStmt([])));
|
||||
|
||||
// redeclarations (TOK_NAME nodes with lexdef)
|
||||
|
||||
assertStmt("function f() { function g() { } function g() { } }",
|
||||
funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])),
|
||||
funDecl(ident("g"), [], blockStmt([]))])));
|
||||
|
||||
assertStmt("function f() { function g() { } function g() { return 42 } }",
|
||||
funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])),
|
||||
funDecl(ident("g"), [], blockStmt([returnStmt(lit(42))]))])));
|
||||
|
||||
assertStmt("function f() { var x = 42; var x = 43; }",
|
||||
funDecl(ident("f"), [], blockStmt([varDecl([declarator(ident("x"),lit(42))]),
|
||||
varDecl([declarator(ident("x"),lit(43))])])));
|
||||
|
||||
// getters and setters
|
||||
|
||||
assertExpr("({ get x() { return 42 } })",
|
||||
objExpr([ objProp(ident("x"),
|
||||
funExpr(null, [], blockStmt([returnStmt(lit(42))])),
|
||||
"get" ) ]));
|
||||
assertExpr("({ set x(v) { return 42 } })",
|
||||
objExpr([ objProp(ident("x"),
|
||||
funExpr(null, [ident("v")], blockStmt([returnStmt(lit(42))])),
|
||||
"set" ) ]));
|
||||
|
||||
}
|
||||
|
||||
exports.testReflect = testReflect;
|
||||
|
||||
}(typeof exports === 'undefined' ? this : exports));
|
67
node_modules/jsonpath/node_modules/esprima/test/run.js
generated
vendored
Normal file
67
node_modules/jsonpath/node_modules/esprima/test/run.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint node:true */
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var child = require('child_process'),
|
||||
nodejs = '"' + process.execPath + '"',
|
||||
ret = 0,
|
||||
suites,
|
||||
index;
|
||||
|
||||
suites = [
|
||||
'runner',
|
||||
'compat',
|
||||
'parselibs'
|
||||
];
|
||||
|
||||
function nextTest() {
|
||||
var suite = suites[index];
|
||||
|
||||
if (index < suites.length) {
|
||||
child.exec(nodejs + ' ./test/' + suite + '.js', function (err, stdout, stderr) {
|
||||
if (stdout) {
|
||||
process.stdout.write(suite + ': ' + stdout);
|
||||
}
|
||||
if (stderr) {
|
||||
process.stderr.write(suite + ': ' + stderr);
|
||||
}
|
||||
if (err) {
|
||||
ret = err.code;
|
||||
}
|
||||
index += 1;
|
||||
nextTest();
|
||||
});
|
||||
} else {
|
||||
process.exit(ret);
|
||||
}
|
||||
}
|
||||
|
||||
index = 0;
|
||||
nextTest();
|
||||
}());
|
495
node_modules/jsonpath/node_modules/esprima/test/runner.js
generated
vendored
Normal file
495
node_modules/jsonpath/node_modules/esprima/test/runner.js
generated
vendored
Normal file
@ -0,0 +1,495 @@
|
||||
/*
|
||||
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
|
||||
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
|
||||
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||
Copyright (C) 2011 Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
Copyright (C) 2011 Arpad Borsos <arpad.borsos@googlemail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint browser:true node:true */
|
||||
/*global esprima:true, testFixture:true */
|
||||
|
||||
var runTests;
|
||||
|
||||
// Special handling for regular expression literal since we need to
|
||||
// convert it to a string literal, otherwise it will be decoded
|
||||
// as object "{}" and the regular expression would be lost.
|
||||
function adjustRegexLiteral(key, value) {
|
||||
'use strict';
|
||||
if (key === 'value' && value instanceof RegExp) {
|
||||
value = value.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function NotMatchingError(expected, actual) {
|
||||
'use strict';
|
||||
Error.call(this, 'Expected ');
|
||||
this.expected = expected;
|
||||
this.actual = actual;
|
||||
}
|
||||
NotMatchingError.prototype = new Error();
|
||||
|
||||
function errorToObject(e) {
|
||||
'use strict';
|
||||
var msg = e.toString();
|
||||
|
||||
// Opera 9.64 produces an non-standard string in toString().
|
||||
if (msg.substr(0, 6) !== 'Error:') {
|
||||
if (typeof e.message === 'string') {
|
||||
msg = 'Error: ' + e.message;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
index: e.index,
|
||||
lineNumber: e.lineNumber,
|
||||
column: e.column,
|
||||
message: msg
|
||||
};
|
||||
}
|
||||
|
||||
function sortedObject(o) {
|
||||
if (o === null) {
|
||||
return o;
|
||||
}
|
||||
if (o instanceof Array) {
|
||||
return o.map(sortedObject);
|
||||
}
|
||||
if (typeof o !== 'object') {
|
||||
return o;
|
||||
}
|
||||
if (o instanceof RegExp) {
|
||||
return o;
|
||||
}
|
||||
var keys = Object.keys(o);
|
||||
var result = {
|
||||
range: undefined,
|
||||
loc: undefined
|
||||
};
|
||||
keys.forEach(function (key) {
|
||||
if (o.hasOwnProperty(key)){
|
||||
result[key] = sortedObject(o[key]);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function hasAttachedComment(syntax) {
|
||||
var key;
|
||||
for (key in syntax) {
|
||||
if (key === 'leadingComments' || key === 'trailingComments') {
|
||||
return true;
|
||||
}
|
||||
if (typeof syntax[key] === 'object' && syntax[key] !== null) {
|
||||
if (hasAttachedComment(syntax[key])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function testParse(esprima, code, syntax) {
|
||||
'use strict';
|
||||
var expected, tree, actual, options, StringObject, i, len, err;
|
||||
|
||||
// alias, so that JSLint does not complain.
|
||||
StringObject = String;
|
||||
|
||||
options = {
|
||||
comment: (typeof syntax.comments !== 'undefined'),
|
||||
range: true,
|
||||
loc: true,
|
||||
tokens: (typeof syntax.tokens !== 'undefined'),
|
||||
raw: true,
|
||||
tolerant: (typeof syntax.errors !== 'undefined'),
|
||||
source: null
|
||||
};
|
||||
|
||||
if (options.comment) {
|
||||
options.attachComment = hasAttachedComment(syntax);
|
||||
}
|
||||
|
||||
if (typeof syntax.tokens !== 'undefined') {
|
||||
if (syntax.tokens.length > 0) {
|
||||
options.range = (typeof syntax.tokens[0].range !== 'undefined');
|
||||
options.loc = (typeof syntax.tokens[0].loc !== 'undefined');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof syntax.comments !== 'undefined') {
|
||||
if (syntax.comments.length > 0) {
|
||||
options.range = (typeof syntax.comments[0].range !== 'undefined');
|
||||
options.loc = (typeof syntax.comments[0].loc !== 'undefined');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.loc) {
|
||||
options.source = syntax.loc.source;
|
||||
}
|
||||
|
||||
syntax = sortedObject(syntax);
|
||||
expected = JSON.stringify(syntax, null, 4);
|
||||
try {
|
||||
// Some variations of the options.
|
||||
tree = esprima.parse(code, { tolerant: options.tolerant });
|
||||
tree = esprima.parse(code, { tolerant: options.tolerant, range: true });
|
||||
tree = esprima.parse(code, { tolerant: options.tolerant, loc: true });
|
||||
|
||||
tree = esprima.parse(code, options);
|
||||
tree = (options.comment || options.tokens || options.tolerant) ? tree : tree.body[0];
|
||||
|
||||
if (options.tolerant) {
|
||||
for (i = 0, len = tree.errors.length; i < len; i += 1) {
|
||||
tree.errors[i] = errorToObject(tree.errors[i]);
|
||||
}
|
||||
}
|
||||
tree = sortedObject(tree);
|
||||
actual = JSON.stringify(tree, adjustRegexLiteral, 4);
|
||||
|
||||
// Only to ensure that there is no error when using string object.
|
||||
esprima.parse(new StringObject(code), options);
|
||||
|
||||
} catch (e) {
|
||||
throw new NotMatchingError(expected, e.toString());
|
||||
}
|
||||
if (expected !== actual) {
|
||||
throw new NotMatchingError(expected, actual);
|
||||
}
|
||||
|
||||
function filter(key, value) {
|
||||
if (key === 'value' && value instanceof RegExp) {
|
||||
value = value.toString();
|
||||
}
|
||||
return (key === 'loc' || key === 'range') ? undefined : value;
|
||||
}
|
||||
|
||||
if (options.tolerant) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check again without any location info.
|
||||
options.range = false;
|
||||
options.loc = false;
|
||||
syntax = sortedObject(syntax);
|
||||
expected = JSON.stringify(syntax, filter, 4);
|
||||
try {
|
||||
tree = esprima.parse(code, options);
|
||||
tree = (options.comment || options.tokens) ? tree : tree.body[0];
|
||||
|
||||
if (options.tolerant) {
|
||||
for (i = 0, len = tree.errors.length; i < len; i += 1) {
|
||||
tree.errors[i] = errorToObject(tree.errors[i]);
|
||||
}
|
||||
}
|
||||
tree = sortedObject(tree);
|
||||
actual = JSON.stringify(tree, filter, 4);
|
||||
} catch (e) {
|
||||
throw new NotMatchingError(expected, e.toString());
|
||||
}
|
||||
if (expected !== actual) {
|
||||
throw new NotMatchingError(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
function testTokenize(esprima, code, tokens) {
|
||||
'use strict';
|
||||
var options, expected, actual, tree;
|
||||
|
||||
options = {
|
||||
comment: true,
|
||||
tolerant: true,
|
||||
loc: true,
|
||||
range: true
|
||||
};
|
||||
|
||||
expected = JSON.stringify(tokens, null, 4);
|
||||
|
||||
try {
|
||||
tree = esprima.tokenize(code, options);
|
||||
actual = JSON.stringify(tree, null, 4);
|
||||
} catch (e) {
|
||||
throw new NotMatchingError(expected, e.toString());
|
||||
}
|
||||
if (expected !== actual) {
|
||||
throw new NotMatchingError(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
function testError(esprima, code, exception) {
|
||||
'use strict';
|
||||
var i, options, expected, actual, err, handleInvalidRegexFlag, tokenize;
|
||||
|
||||
// Different parsing options should give the same error.
|
||||
options = [
|
||||
{},
|
||||
{ comment: true },
|
||||
{ raw: true },
|
||||
{ raw: true, comment: true }
|
||||
];
|
||||
|
||||
// If handleInvalidRegexFlag is true, an invalid flag in a regular expression
|
||||
// will throw an exception. In some old version V8, this is not the case
|
||||
// and hence handleInvalidRegexFlag is false.
|
||||
handleInvalidRegexFlag = false;
|
||||
try {
|
||||
'test'.match(new RegExp('[a-z]', 'x'));
|
||||
} catch (e) {
|
||||
handleInvalidRegexFlag = true;
|
||||
}
|
||||
|
||||
exception.description = exception.message.replace(/Error: Line [0-9]+: /, '');
|
||||
|
||||
if (exception.tokenize) {
|
||||
tokenize = true;
|
||||
exception.tokenize = undefined;
|
||||
}
|
||||
expected = JSON.stringify(exception);
|
||||
|
||||
for (i = 0; i < options.length; i += 1) {
|
||||
|
||||
try {
|
||||
if (tokenize) {
|
||||
esprima.tokenize(code, options[i])
|
||||
} else {
|
||||
esprima.parse(code, options[i]);
|
||||
}
|
||||
} catch (e) {
|
||||
err = errorToObject(e);
|
||||
err.description = e.description;
|
||||
actual = JSON.stringify(err);
|
||||
}
|
||||
|
||||
if (expected !== actual) {
|
||||
|
||||
// Compensate for old V8 which does not handle invalid flag.
|
||||
if (exception.message.indexOf('Invalid regular expression') > 0) {
|
||||
if (typeof actual === 'undefined' && !handleInvalidRegexFlag) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotMatchingError(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function testAPI(esprima, code, result) {
|
||||
'use strict';
|
||||
var expected, res, actual;
|
||||
|
||||
expected = JSON.stringify(result.result, null, 4);
|
||||
try {
|
||||
if (typeof result.property !== 'undefined') {
|
||||
res = esprima[result.property];
|
||||
} else {
|
||||
res = esprima[result.call].apply(esprima, result.args);
|
||||
}
|
||||
actual = JSON.stringify(res, adjustRegexLiteral, 4);
|
||||
} catch (e) {
|
||||
throw new NotMatchingError(expected, e.toString());
|
||||
}
|
||||
if (expected !== actual) {
|
||||
throw new NotMatchingError(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
function runTest(esprima, code, result) {
|
||||
'use strict';
|
||||
if (result.hasOwnProperty('lineNumber')) {
|
||||
testError(esprima, code, result);
|
||||
} else if (result.hasOwnProperty('result')) {
|
||||
testAPI(esprima, code, result);
|
||||
} else if (result instanceof Array) {
|
||||
testTokenize(esprima, code, result);
|
||||
} else {
|
||||
testParse(esprima, code, result);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
// Run all tests in a browser environment.
|
||||
runTests = function () {
|
||||
'use strict';
|
||||
var total = 0,
|
||||
failures = 0,
|
||||
category,
|
||||
fixture,
|
||||
source,
|
||||
tick,
|
||||
expected,
|
||||
index,
|
||||
len;
|
||||
|
||||
function setText(el, str) {
|
||||
if (typeof el.innerText === 'string') {
|
||||
el.innerText = str;
|
||||
} else {
|
||||
el.textContent = str;
|
||||
}
|
||||
}
|
||||
|
||||
function startCategory(category) {
|
||||
var report, e;
|
||||
report = document.getElementById('report');
|
||||
e = document.createElement('h4');
|
||||
setText(e, category);
|
||||
report.appendChild(e);
|
||||
}
|
||||
|
||||
function reportSuccess(code) {
|
||||
var report, e;
|
||||
report = document.getElementById('report');
|
||||
e = document.createElement('pre');
|
||||
e.setAttribute('class', 'code');
|
||||
setText(e, code);
|
||||
report.appendChild(e);
|
||||
}
|
||||
|
||||
function reportFailure(code, expected, actual) {
|
||||
var report, e;
|
||||
|
||||
report = document.getElementById('report');
|
||||
|
||||
e = document.createElement('p');
|
||||
setText(e, 'Code:');
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('pre');
|
||||
e.setAttribute('class', 'code');
|
||||
setText(e, code);
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('p');
|
||||
setText(e, 'Expected');
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('pre');
|
||||
e.setAttribute('class', 'expected');
|
||||
setText(e, expected);
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('p');
|
||||
setText(e, 'Actual');
|
||||
report.appendChild(e);
|
||||
|
||||
e = document.createElement('pre');
|
||||
e.setAttribute('class', 'actual');
|
||||
setText(e, actual);
|
||||
report.appendChild(e);
|
||||
}
|
||||
|
||||
setText(document.getElementById('version'), esprima.version);
|
||||
|
||||
tick = new Date();
|
||||
for (category in testFixture) {
|
||||
if (testFixture.hasOwnProperty(category)) {
|
||||
startCategory(category);
|
||||
fixture = testFixture[category];
|
||||
for (source in fixture) {
|
||||
if (fixture.hasOwnProperty(source)) {
|
||||
expected = fixture[source];
|
||||
total += 1;
|
||||
try {
|
||||
runTest(esprima, source, expected);
|
||||
reportSuccess(source, JSON.stringify(expected, null, 4));
|
||||
} catch (e) {
|
||||
failures += 1;
|
||||
reportFailure(source, e.expected, e.actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tick = (new Date()) - tick;
|
||||
|
||||
if (failures > 0) {
|
||||
document.getElementById('status').className = 'alert-box alert';
|
||||
setText(document.getElementById('status'), total + ' tests. ' +
|
||||
'Failures: ' + failures + '. ' + tick + ' ms.');
|
||||
} else {
|
||||
document.getElementById('status').className = 'alert-box success';
|
||||
setText(document.getElementById('status'), total + ' tests. ' +
|
||||
'No failure. ' + tick + ' ms.');
|
||||
}
|
||||
};
|
||||
} else {
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var esprima = require('../esprima'),
|
||||
vm = require('vm'),
|
||||
fs = require('fs'),
|
||||
diff = require('json-diff').diffString,
|
||||
total = 0,
|
||||
failures = [],
|
||||
tick = new Date(),
|
||||
expected,
|
||||
header;
|
||||
|
||||
vm.runInThisContext(fs.readFileSync(__dirname + '/test.js', 'utf-8'));
|
||||
|
||||
Object.keys(testFixture).forEach(function (category) {
|
||||
Object.keys(testFixture[category]).forEach(function (source) {
|
||||
total += 1;
|
||||
expected = testFixture[category][source];
|
||||
try {
|
||||
runTest(esprima, source, expected);
|
||||
} catch (e) {
|
||||
e.source = source;
|
||||
failures.push(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
tick = (new Date()) - tick;
|
||||
|
||||
header = total + ' tests. ' + failures.length + ' failures. ' +
|
||||
tick + ' ms';
|
||||
if (failures.length) {
|
||||
console.error(header);
|
||||
failures.forEach(function (failure) {
|
||||
try {
|
||||
var expectedObject = JSON.parse(failure.expected);
|
||||
var actualObject = JSON.parse(failure.actual);
|
||||
|
||||
console.error(failure.source + ': Expected\n ' +
|
||||
failure.expected.split('\n').join('\n ') +
|
||||
'\nto match\n ' + failure.actual + '\nDiff:\n' +
|
||||
diff(expectedObject, actualObject));
|
||||
} catch (ex) {
|
||||
console.error(failure.source + ': Expected\n ' +
|
||||
failure.expected.split('\n').join('\n ') +
|
||||
'\nto match\n ' + failure.actual);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log(header);
|
||||
}
|
||||
process.exit(failures.length === 0 ? 0 : 1);
|
||||
}());
|
||||
}
|
25241
node_modules/jsonpath/node_modules/esprima/test/test.js
generated
vendored
Normal file
25241
node_modules/jsonpath/node_modules/esprima/test/test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
23
node_modules/jsonpath/node_modules/underscore/LICENSE
generated
vendored
Normal file
23
node_modules/jsonpath/node_modules/underscore/LICENSE
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
Copyright (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Reporters & Editors
|
||||
|
||||
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.
|
28
node_modules/jsonpath/node_modules/underscore/README.md
generated
vendored
Normal file
28
node_modules/jsonpath/node_modules/underscore/README.md
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
__
|
||||
/\ \ __
|
||||
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
|
||||
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
|
||||
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
|
||||
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
|
||||
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
|
||||
\ \____/
|
||||
\/___/
|
||||
|
||||
Underscore.js is a utility-belt library for JavaScript that provides
|
||||
support for the usual functional suspects (each, map, reduce, filter...)
|
||||
without extending any core JavaScript objects.
|
||||
|
||||
For Docs, License, Tests, and pre-packed downloads, see:
|
||||
https://underscorejs.org
|
||||
|
||||
For support and questions, please use
|
||||
[the gitter channel](https://gitter.im/jashkenas/underscore)
|
||||
or [stackoverflow](https://stackoverflow.com/search?q=underscore.js)
|
||||
|
||||
Underscore is an open-sourced component of DocumentCloud:
|
||||
https://github.com/documentcloud
|
||||
|
||||
Many thanks to our contributors:
|
||||
https://github.com/jashkenas/underscore/contributors
|
||||
|
||||
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
|
7
node_modules/jsonpath/node_modules/underscore/amd/_apply.js
generated
vendored
Normal file
7
node_modules/jsonpath/node_modules/underscore/amd/_apply.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
define(['./_setup', './_unmethodize'], function (_setup, _unmethodize) {
|
||||
|
||||
var apply = _unmethodize(_setup.apply);
|
||||
|
||||
return apply;
|
||||
|
||||
});
|
14
node_modules/jsonpath/node_modules/underscore/amd/_applyProperty.js
generated
vendored
Normal file
14
node_modules/jsonpath/node_modules/underscore/amd/_applyProperty.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
define(function () {
|
||||
|
||||
// Internal helper that wraps an `iteratee` to call it with the
|
||||
// property of a closed-over `object`. Useful when iterating over
|
||||
// an array of keys of `object`.
|
||||
function applyProperty(iteratee, object) {
|
||||
return function(key) {
|
||||
return iteratee(object[key], key, object);
|
||||
};
|
||||
}
|
||||
|
||||
return applyProperty;
|
||||
|
||||
});
|
11
node_modules/jsonpath/node_modules/underscore/amd/_arrayAccessors.js
generated
vendored
Normal file
11
node_modules/jsonpath/node_modules/underscore/amd/_arrayAccessors.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
define(['exports', './concat', './join', './slice'], function (exports, concat, join, slice) {
|
||||
|
||||
|
||||
|
||||
exports.concat = concat;
|
||||
exports.join = join;
|
||||
exports.slice = slice;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
});
|
15
node_modules/jsonpath/node_modules/underscore/amd/_arrayMutators.js
generated
vendored
Normal file
15
node_modules/jsonpath/node_modules/underscore/amd/_arrayMutators.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
define(['exports', './pop', './push', './reverse', './shift', './sort', './splice', './unshift'], function (exports, pop, push, reverse, shift, sort, splice, unshift) {
|
||||
|
||||
|
||||
|
||||
exports.pop = pop;
|
||||
exports.push = push;
|
||||
exports.reverse = reverse;
|
||||
exports.shift = shift;
|
||||
exports.sort = sort;
|
||||
exports.splice = splice;
|
||||
exports.unshift = unshift;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
});
|
21
node_modules/jsonpath/node_modules/underscore/amd/_baseCreate.js
generated
vendored
Normal file
21
node_modules/jsonpath/node_modules/underscore/amd/_baseCreate.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
define(['./isObject', './_setup'], function (isObject, _setup) {
|
||||
|
||||
// Create a naked function reference for surrogate-prototype-swapping.
|
||||
function ctor() {
|
||||
return function(){};
|
||||
}
|
||||
|
||||
// An internal function for creating a new object that inherits from another.
|
||||
function baseCreate(prototype) {
|
||||
if (!isObject(prototype)) return {};
|
||||
if (_setup.nativeCreate) return _setup.nativeCreate(prototype);
|
||||
var Ctor = ctor();
|
||||
Ctor.prototype = prototype;
|
||||
var result = new Ctor;
|
||||
Ctor.prototype = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
return baseCreate;
|
||||
|
||||
});
|
15
node_modules/jsonpath/node_modules/underscore/amd/_baseIteratee.js
generated
vendored
Normal file
15
node_modules/jsonpath/node_modules/underscore/amd/_baseIteratee.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
define(['./isObject', './identity', './isFunction', './isArray', './matcher', './property', './_optimizeCb'], function (isObject, identity, isFunction, isArray, matcher, property, _optimizeCb) {
|
||||
|
||||
// An internal function to generate callbacks that can be applied to each
|
||||
// element in a collection, returning the desired result — either `_.identity`,
|
||||
// an arbitrary callback, a property matcher, or a property accessor.
|
||||
function baseIteratee(value, context, argCount) {
|
||||
if (value == null) return identity;
|
||||
if (isFunction(value)) return _optimizeCb(value, context, argCount);
|
||||
if (isObject(value) && !isArray(value)) return matcher(value);
|
||||
return property(value);
|
||||
}
|
||||
|
||||
return baseIteratee;
|
||||
|
||||
});
|
17
node_modules/jsonpath/node_modules/underscore/amd/_binarySearch.js
generated
vendored
Normal file
17
node_modules/jsonpath/node_modules/underscore/amd/_binarySearch.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
define(['./_getLength'], function (_getLength) {
|
||||
|
||||
// Iteratively cut `array` in half to figure out the index at which `obj` should
|
||||
// be inserted so as to maintain the order defined by `compare`.
|
||||
function binarySearch(array, obj, iteratee, compare) {
|
||||
var value = iteratee(obj);
|
||||
var low = 0, high = _getLength(array);
|
||||
while (low < high) {
|
||||
var mid = Math.floor((low + high) / 2);
|
||||
if (compare(iteratee(array[mid]), value)) low = mid + 1; else high = mid;
|
||||
}
|
||||
return low;
|
||||
}
|
||||
|
||||
return binarySearch;
|
||||
|
||||
});
|
14
node_modules/jsonpath/node_modules/underscore/amd/_bindCb.js
generated
vendored
Normal file
14
node_modules/jsonpath/node_modules/underscore/amd/_bindCb.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
define(function () {
|
||||
|
||||
// Internal function that returns a bound version of the passed-in callback, to
|
||||
// be repeatedly applied in other Underscore functions.
|
||||
function bindCb(func, context) {
|
||||
if (context === void 0) return func;
|
||||
return function() {
|
||||
return func.apply(context, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
return bindCb;
|
||||
|
||||
});
|
17
node_modules/jsonpath/node_modules/underscore/amd/_bindCb4.js
generated
vendored
Normal file
17
node_modules/jsonpath/node_modules/underscore/amd/_bindCb4.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
define(function () {
|
||||
|
||||
// In Firefox, `Function.prototype.call` is faster than
|
||||
// `Function.prototype.apply`. In the optimized variant of
|
||||
// `bindCb` below, we exploit the fact that no Underscore
|
||||
// function passes more than four arguments to a callback.
|
||||
// **NOT general enough for use outside of Underscore.**
|
||||
function bindCb4(func, context) {
|
||||
if (context === void 0) return func;
|
||||
return function(a1, a2, a3, a4) {
|
||||
return func.call(context, a1, a2, a3, a4);
|
||||
};
|
||||
}
|
||||
|
||||
return bindCb4;
|
||||
|
||||
});
|
11
node_modules/jsonpath/node_modules/underscore/amd/_byValue.js
generated
vendored
Normal file
11
node_modules/jsonpath/node_modules/underscore/amd/_byValue.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
define(function () {
|
||||
|
||||
// Internal wrapper to enable match-by-value mode in `linearSearch`.
|
||||
function byValue(value) {
|
||||
if (!(this instanceof byValue)) return new byValue(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
return byValue;
|
||||
|
||||
});
|
12
node_modules/jsonpath/node_modules/underscore/amd/_cb.js
generated
vendored
Normal file
12
node_modules/jsonpath/node_modules/underscore/amd/_cb.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
define(['./underscore', './_baseIteratee', './iteratee'], function (underscore, _baseIteratee, iteratee) {
|
||||
|
||||
// The function we call internally to generate a callback. It invokes
|
||||
// `_.iteratee` if overridden, otherwise `baseIteratee`.
|
||||
function cb(value, context, argCount) {
|
||||
if (underscore.iteratee !== iteratee) return underscore.iteratee(value, context);
|
||||
return _baseIteratee(value, context, argCount);
|
||||
}
|
||||
|
||||
return cb;
|
||||
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user