Skip to content

Commit

Permalink
adding files
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolalysenko committed Jul 18, 2013
0 parents commit 0a85ea5
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
@@ -0,0 +1,16 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules/*
*.DS_Store
17 changes: 17 additions & 0 deletions .npmignore
@@ -0,0 +1,17 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules/*
*.DS_Store
test/*
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@

The MIT License (MIT)

Copyright (c) 2013 Mikola Lysenko

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 changes: 28 additions & 0 deletions README.md
@@ -0,0 +1,28 @@
is-property
===========
Tests if a property of a JavaScript object can be accessed using the dot (.) notation or if it must be enclosed in brackets, (ie use x[" ... "])

Example
-------

```javascript
var isProperty = require("is-property")

console.log(isProperty("foo")) //Prints true
console.log(isProperty("0")) //Prints false
```

Install
-------

npm install is-property

### `require("is-property")(str)`
Checks if str is a property

* `str` is a string which we will test if it is a property or not

**Returns** true or false depending if str is a property

## Credits
(c) 2013 Mikola Lysenko. MIT License
5 changes: 5 additions & 0 deletions is-property.js
@@ -0,0 +1,5 @@
"use strict"
function isProperty(str) {
return /^[^0-9\/\\.\-+*!~()\[\];:?'"<>,{}|`~%\^& \f\n\r\t\v​\u00a0\u1680​\u180e\u2000​\u2001\u2002​\u2003\u2004​\u2005\u2006​\u2007\u2008​\u2009\u200a​\u2028\u2029​​\u202f\u205f​\u3000]\w*$/.test(str)
}
module.exports = isProperty
15 changes: 15 additions & 0 deletions test/test.js
@@ -0,0 +1,15 @@
"use strict"
var isProperty = require("../is-property.js")
require("tape")("is-property", function(t) {

t.assert(isProperty("foo"))
t.assert(!isProperty(".foo"))
t.assert(!isProperty("a.b.c"))
t.assert(isProperty("_joke"))
t.assert(isProperty("j_a_b_c"))
t.assert(isProperty("f00"))
t.assert(!isProperty("0bad"))
t.assert(isProperty("break"))

t.end()
})

0 comments on commit 0a85ea5

Please sign in to comment.