Send to zulip

This commit is contained in:
Koper
2023-11-20 21:39:33 +07:00
parent 82f50817f8
commit ba40d28152
3609 changed files with 2311843 additions and 7 deletions

View File

@@ -0,0 +1,19 @@
Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.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.

View File

@@ -0,0 +1,123 @@
<h1 align=center>
<a href="http://chaijs.com" title="Chai Documentation">
<img alt="ChaiJS" src="http://chaijs.com/img/chai-logo.png"/>
<br>
get-func-name
</a>
</h1>
<p align=center>
Utility for getting a function's name for <a href="http://nodejs.org">node</a> and the browser.
</p>
<p align=center>
<a href="./LICENSE">
<img
alt="license:mit"
src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square"
/>
</a>
<a href="https://github.com/chaijs/get-func-name/releases">
<img
alt="tag:?"
src="https://img.shields.io/github/tag/chaijs/get-func-name.svg?style=flat-square"
/>
</a>
<a href="https://travis-ci.org/chaijs/get-func-name">
<img
alt="build:?"
src="https://img.shields.io/travis/chaijs/get-func-name/master.svg?style=flat-square"
/>
</a>
<a href="https://coveralls.io/r/chaijs/get-func-name">
<img
alt="coverage:?"
src="https://img.shields.io/coveralls/chaijs/get-func-name/master.svg?style=flat-square"
/>
</a>
<a href="https://www.npmjs.com/packages/get-func-name">
<img
alt="npm:?"
src="https://img.shields.io/npm/v/get-func-name.svg?style=flat-square"
/>
</a>
<a href="https://www.npmjs.com/packages/get-func-name">
<img
alt="dependencies:?"
src="https://img.shields.io/npm/dm/get-func-name.svg?style=flat-square"
/>
</a>
<a href="">
<img
alt="devDependencies:?"
src="https://img.shields.io/david/chaijs/get-func-name.svg?style=flat-square"
/>
</a>
<br/>
<a href="https://saucelabs.com/u/chaijs-get-func-name">
<img
alt="Selenium Test Status"
src="https://saucelabs.com/browser-matrix/chaijs-get-func-name.svg"
/>
</a>
<br>
<a href="https://chai-slack.herokuapp.com/">
<img
alt="Join the Slack chat"
src="https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square"
/>
</a>
<a href="https://gitter.im/chaijs/chai">
<img
alt="Join the Gitter chat"
src="https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square"
/>
</a>
</p>
## What is get-func-name?
This is a module to retrieve a function's name securely and consistently both in NodeJS and the browser.
## Installation
### Node.js
`get-func-name` is available on [npm](http://npmjs.org). To install it, type:
$ npm install get-func-name
### Browsers
You can also use it within the browser; install via npm and use the `get-func-name.js` file found within the download. For example:
```html
<script src="./node_modules/get-func-name/get-func-name.js"></script>
```
## Usage
The module `get-func-name` exports the following method:
* `getFuncName(fn)` - Returns the name of a function.
```js
var getFuncName = require('get-func-name');
```
#### .getFuncName(fun)
```js
var getFuncName = require('get-func-name');
var unknownFunction = function myCoolFunction(word) {
return word + 'is cool';
};
var anonymousFunction = (function () {
return function () {};
}());
getFuncName(unknownFunction) // 'myCoolFunction'
getFuncName(anonymousFunction) // ''
```

View File

@@ -0,0 +1 @@
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({},{},[])

View File

@@ -0,0 +1,52 @@
'use strict';
/* !
* Chai - getFuncName utility
* Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
/**
* ### .getFuncName(constructorFn)
*
* Returns the name of a function.
* When a non-function instance is passed, returns `null`.
* This also includes a polyfill function if `aFunc.name` is not defined.
*
* @name getFuncName
* @param {Function} funct
* @namespace Utils
* @api public
*/
var toString = Function.prototype.toString;
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
var maxFunctionSourceLength = 512;
function getFuncName(aFunc) {
if (typeof aFunc !== 'function') {
return null;
}
var name = '';
if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') {
// eslint-disable-next-line prefer-reflect
var functionSource = toString.call(aFunc);
// To avoid unconstrained resource consumption due to pathalogically large function names,
// we limit the available return value to be less than 512 characters.
if (functionSource.indexOf('(') > maxFunctionSourceLength) {
return name;
}
// Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined
var match = functionSource.match(functionNameMatch);
if (match) {
name = match[1];
}
} else {
// If we've got a `name` property we just use it
name = aFunc.name;
}
return name;
}
module.exports = getFuncName;

View File

@@ -0,0 +1,85 @@
{
"name": "get-func-name",
"version": "2.0.2",
"description": "Utility for getting a function's name for node and the browser",
"keywords": [
"get-func-name",
"chai util"
],
"license": "MIT",
"author": "Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)",
"contributors": [
"Keith Cirkel (https://github.com/keithamus)",
"Lucas Fernandes da Costa (https://github.com/lucasfcosta)",
"Grant Snodgrass (https://github.com/meeber)",
"Lucas Vieira (https://github.com/vieiralucas)",
"Aleksey Shvayka (https://github.com/shvaikalesh)"
],
"files": [
"index.js",
"get-func-name.js"
],
"main": "./index.js",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/chaijs/get-func-name.git"
},
"scripts": {
"build": "browserify --bare $npm_package_main --standalone getFuncName -o get-func-name.js",
"lint": "eslint --ignore-path .gitignore .",
"prepublish": "npm run build",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"pretest": "npm run lint",
"test": "npm run test:node && npm run test:browser && npm run upload-coverage",
"test:browser": "karma start --singleRun=true",
"test:node": "istanbul cover _mocha",
"upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0"
},
"config": {
"ghooks": {
"commit-msg": "validate-commit-msg"
}
},
"eslintConfig": {
"extends": [
"strict/es5"
],
"env": {
"es6": true
},
"globals": {
"HTMLElement": false
},
"rules": {
"complexity": 0,
"max-statements": 0
}
},
"dependencies": {},
"devDependencies": {
"browserify": "^13.0.0",
"browserify-istanbul": "^2.0.0",
"coveralls": "2.11.14",
"eslint": "^2.4.0",
"eslint-config-strict": "^9.1.0",
"eslint-plugin-filenames": "^1.1.0",
"ghooks": "^1.0.1",
"istanbul": "^0.4.2",
"karma": "^1.3.0",
"karma-browserify": "^5.0.2",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sauce-launcher": "^1.0.0",
"lcov-result-merger": "^1.0.2",
"mocha": "^3.1.2",
"phantomjs-prebuilt": "^2.1.5",
"semantic-release": "^4.3.5",
"simple-assert": "^1.0.0",
"travis-after-all": "^1.4.4",
"validate-commit-msg": "^2.3.1"
},
"engines": {
"node": "*"
}
}