Skip to content

Commit

Permalink
Convert project to an ES module (#28)
Browse files Browse the repository at this point in the history
* Replace simple-assert with a throw

* Convert project to ES module

* Simplify karma config

* Remove unused dependencies

* Set `engines` key to node >= 12

* Remove `.travis.yml`

* Add back dependencies that are actually needed

* Update eslint and friends

* Remove obsolete build npm script

Co-authored-by: Keith Cirkel <[email protected]>
  • Loading branch information
koddsson and keithamus authored Oct 8, 2021
1 parent 6b72548 commit 1436af2
Show file tree
Hide file tree
Showing 7 changed files with 8,993 additions and 169 deletions.
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

22 changes: 8 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
'use strict';

/* !
* Chai - getFuncName utility
* Copyright(c) 2012-2016 Jake Luer <[email protected]>
* MIT Licensed
*/

/**
* ### .getFuncName(constructorFn)
*
Expand All @@ -19,26 +11,28 @@
* @api public
*/

var toString = Function.prototype.toString;
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
const { toString } = Function.prototype;
const functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*/)]+\*\/\s*)*([^\s(/]+)/;
function getFuncName(aFunc) {
if (typeof aFunc !== 'function') {
return null;
}

var name = '';
let name = '';
if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') {
// Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined
var match = toString.call(aFunc).match(functionNameMatch);
// eslint-disable-next-line prefer-reflect
const match = toString.call(aFunc).match(functionNameMatch);
if (match) {
name = match[1];
[ name ] = match;
}
} else {
// If we've got a `name` property we just use it
// eslint-disable-next-line prefer-destructuring
name = aFunc.name;
}

return name;
}

module.exports = getFuncName;
export { getFuncName };
15 changes: 15 additions & 0 deletions karma.conf.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = function configureKarma(config) {
config.set({
basePath: '.',
browsers: [ 'ChromeHeadless' ],
frameworks: [ 'mocha' ],
files: [
{ pattern: './index.js', type: 'module' },
{ pattern: './test/*.js', type: 'module' },
],
reporters: [ 'progress' ],
colors: true,
autoWatch: false,
singleRun: true,
});
};
96 changes: 0 additions & 96 deletions karma.conf.js

This file was deleted.

Loading

0 comments on commit 1436af2

Please sign in to comment.