npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cocotte-name

v0.1.0

Published

property name check

Downloads

2

Readme

cocotte-name

property name check

変数名が使用可能かを確認します。
このモジュールは、viewで処理を記述する際に使用できるフィールドを指定するために使用します。

条件

使用可能な条件は以下の通りです

  • 後述する予約語ではない
  • 半角英数文字と_で構成される
  • 英字で始まる
  • _を最後にする事はできない
  • 1文字以上32文字以内である

使用方法

要件を満たさない場合は例外を発生させます

var nameCheck = require('cocotte-name');

nameCheck('abc');  // pass
nameCheck('123');  // throw error
nameCheck('ab_c'); // pass
nameCheck('ab_');  // throw error
nameCheck('');     // throw error
nameCheck('abcdefghijabcdefghijabcdefghijabcdefghij'); // throw error
nameCheck('if');        // throw error;
nameCheck('window');    // throw error;
nameCheck('undefined'); // throw error;

判定結果を例外の発生の有無ではなく真偽値で取得したい場合は、第二引数にtrueを指定してください

if (nameCheck('abc', true)) {
  var name = 'abc';
}

予約語

次の単語は名称に使用出来ません

  • $
  • ApplicationCache
  • Arguments
  • Array
  • ArrayBuffer
  • ArrayBufferView
  • Attr
  • Audio
  • BeforeUploadEvent
  • Blob
  • BlobBuilder
  • Boolean
  • Buffer
  • Button
  • CSSRule
  • CSSStyleDeclaration
  • CSSStyleSheet
  • Canvas
  • CanvasGradient
  • CanvasPattern
  • CanvasRenderingContext2D
  • ClientRect
  • CloseEvent
  • Comment
  • Console
  • ConsoleCommandLine
  • DOMException
  • DOMImplementation
  • DOMSettableTokenList
  • DOMTokenList
  • DTRACE_HTTP_CLIENT_REQUEST
  • DTRACE_HTTP_CLIENT_RESPONSE
  • DTRACE_HTTP_SERVER_REQUEST
  • DTRACE_HTTP_SERVER_RESPONSE
  • DTRACE_NET_SERVER_CONNECTION
  • DTRACE_NET_SOCKET_READ
  • DTRACE_NET_SOCKET_WRITE
  • DTRACE_NET_STREAM_END
  • DataTransfer
  • DataView
  • Date
  • Document
  • DocumentFragment
  • DocumentType
  • Element
  • Error
  • ErrorEvent
  • EvalError
  • Event
  • EventSource
  • EventTarget
  • FieldSet
  • File
  • FileError
  • FileReader
  • FileReaderSync
  • Form
  • FormControl
  • FormData
  • FormValidity
  • Function
  • GLOBAL
  • Gelocation
  • Geocoordinates
  • GeolocationError
  • Geoposition
  • Global
  • HTMLCollection
  • HTMLFormControlsCollection
  • HTMLOptionsCollection
  • HashChangeEvent
  • Histroy
  • IFrame
  • Image
  • ImageData
  • Infinity
  • Input
  • JSON
  • Label
  • Link
  • Location
  • Math
  • MediaElement
  • MediaError
  • MessageChannel
  • MessageEvent
  • MessagePort
  • Meter
  • NaN
  • Navigator
  • Node
  • NodeList
  • Number
  • Object
  • Option
  • Output
  • PageTransitionEvent
  • PopStateEvent
  • ProcessingInstruction
  • ProgressEvent
  • RangeError
  • ReferenceError
  • RegExp
  • Screen
  • Script
  • Select
  • Storage
  • StorageEvent
  • String
  • Style
  • SyntaxError
  • Table
  • TableCell
  • TableRow
  • TableSection
  • Text
  • TextArea
  • TextMetrics
  • TimeRanges
  • TypeError
  • TypedArray
  • URIError
  • URL
  • Video
  • WebSocket
  • Window
  • Worker
  • WorkerGlobalScope
  • WorkerLocation
  • WorkerNavigator
  • XMLHttpRequest
  • XMLHttpRequestUpload
  • _
  • __dirname
  • __filename
  • _events
  • _maxListeners
  • abstract
  • addListener
  • alert
  • arguments
  • boolean
  • break
  • byte
  • case
  • catch
  • char
  • class
  • clearImmediate
  • clearInterval
  • clearTimeout
  • console
  • const
  • continue
  • debugger
  • decodeURI
  • decodeURIComponent
  • default
  • define
  • delete
  • do
  • document
  • domain
  • double
  • else
  • emit
  • encodeURI
  • encodeURIComponent
  • enum
  • escape
  • eval
  • export
  • exports
  • extends
  • false
  • final
  • finally
  • float
  • for
  • function
  • global
  • goto
  • if
  • implements
  • import
  • in
  • instanceof
  • int
  • interface
  • isFinite
  • isNaN
  • jQuery
  • let
  • listeners
  • long
  • module
  • native
  • new
  • null
  • on
  • once
  • package
  • parseFloat
  • parseInt
  • private
  • process
  • protected
  • public
  • removeAllListeners
  • removeListener
  • require
  • requirejs
  • return
  • root
  • setImmediate
  • setInterval
  • setMaxListeners
  • setTimeout
  • short
  • static
  • super
  • switch
  • synchronized
  • this
  • throw
  • throws
  • transient
  • true
  • try
  • typeof
  • undefined
  • unescape
  • var
  • void
  • volatile
  • while
  • window
  • with
  • yield