Skip to content
This repository was archived by the owner on Sep 8, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ exports.dollarQuotedString = function(val) {

exports.ident = function(val){
assert(null != val, 'identifier required');
return validIdent(val) ? val : quoteIdent(val);
return reserved[val] || /^[a-z_][a-z0-9_$]*$/.test(val) ? quoteIdent(val) : val;
};

/**
Expand All @@ -129,19 +129,6 @@ exports.literal = function(val){
return prefix + "'" + val + "'";
};

/**
* Check if `id` is a valid unquoted identifier.
*
* @param {String} id
* @return {Boolean}
* @api private
*/

function validIdent(id) {
if (reserved[id]) return false;
return /^[a-z_][a-z0-9_$]*$/i.test(id);
}

/**
* Quote identifier.
*
Expand Down