![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Dress is a javascript helper library which includes basic functional programming methods and commonly used shortcuts. You can use Dress for your browser application or your node.js application.
Note: This library is still experimental, please do not use this in a production project for now. Many methods may change or delete until the beta or stable version release.
To use Dress in your node project, first install the module.
npm install dress
After npm installation run this command in the beggining of your project.(e.g. app.js)
require('dress');
Download index.min.js
and load in the beggining of head tag.
<script src="../path/index.min.js"></script>
[1, 2, 3].$map(function(item){ return item + 1 });
=> [2, 3, 4]
array = [1, 2, 3]
array.$$map(function(item){ return item + 1 })
console.log(array)
=> [2, 3, 4]
[5, 3, 2, 6].$first()
=> 5
[5, 3, 2, 6].$last()
=> 6
people = [
{ name: 'Albert Einstein', birthPlace: 'Ulm, Germany' },
{ name: 'Nikola Tesla', birthPlace: 'Smiljan, Croatia' }
]
people.$find(function(item){
return item.name == 'Nikola Tesla'
}).birthPlace
=> "Smiljan, Croatia"
[1, 4, 9, 3].$contains(3)
=> true
[1, 4, 9, 3].$contains(2)
=> false
[5, 3, -2, 11, -3].$max()
=> 11
[5, 3, -2, 11, -3].$min()
=> -3
[5, 3, -2, 11, -3].$sort()
=> [-3, -2, 3, 5, 11]
array = [{ a: 1, b: 6}, { a: 9, b: 3}, { b: 7, c: 1}]
array.$sort(function(item){
return item.b
})
=> [{ a: 9, b: 3}, { a: 1, b: 6}, { b: 7, c: 1}]
array = [5, 3, -2, 11, -3]
array.$$sort()
console.log(array)
=> [-3, -2, 3, 5, 11]
[5, 3, -2, 11, -3].$sample()
=> 11
[5, 3, -2, 11, -3].$sample()
=> 3
[5, 3, -2, 11, -3].samples(2)
=> [-3, 5]
[5, 3, -2, 11, -3].samples()
=> [11]
array = [5, 3, -2, 11, -3]
array.$$samples(3)
console.log(array)
=> [11, -2]
array = [5, 3, -2]
array.$each(function(item){
console.log(item)
})
=> 5
=> 3
=> -2
array = [
{ a: 1, b: 2 },
{ a: 2, c: 8},
{ a: -5, c: 8}
]
array.$where({ c: 8 })
=> [{ a: 2, c: 8 }, { a: -5, c: 8 }]
array.$where({ a: 2, c: 8 })
=> [{ a: 2, c: 8 }]
array = [
{ a: 1, b: 2 },
{ a: 2, c: 8},
{ a: -5, c: 8}
]
array.$$where({ a: -5 })
console.log(array)
=> [{ a: -5, c: 8 }]
[1, 2, 3, 4, 5, 6].$reject(function(item){
return item % 2 == 0
})
=> [1, 3, 5]
array = [1, 2, 3, 4, 5, 6]
array.$$reject(function(item){
return item % 2 == 0
})
console.log(array)
=> [1, 3, 5]
[4, 2, 8, 3].take(2)
=> [4, 2]
array = [4, 2, 8, 3]
array.$$take(3)
console.log(array)
=> [4, 2, 8]
[4, 2, 8, 3].drop(2)
=> [8, 3]
array = [4, 2, 8, 3]
array.$$drop(1)
console.log(array)
=> [2, 8, 3]
[[1, 4, 2], [3, 2, 5]].$invoke('$drop', 2)
=> [[2], [5]]
array = [[1, 4, 2], [3, 2, 5]]
array.$$invoke('$drop', 2)
console.log(array)
=> [[2], [5]]
[{ a: 1, b: 2 }, { a: 7, b: 6 }, { a: 9 }].$pluck('a')
=> [1, 7, 9]
array = [{ a: 1, b: 2 }, { a: 7, b: 6 }, { a: 9 }]
array.$$pluck('a')
console.log(array)
=> [1, 7, 9]
array = [1.7, 4.3, 4.9]
array.$group(function(item){ return Math.floor(item) })
=> { '1': [1.7], '4': [4.3, 4.9]}
array = ['this', 'is', 'test']
array.$group('length')
=> { '2' : ['is'], '4': ['this', 'test'] }
array = [1, 2, 3, 4, 5]
array.$count(function(item){
return item % 2 == 0 ? 'even': 'odd';
})
=> { odd: 3, even: 2 }
[1, 2, 3, 4, 5].$shuffle()
=> [3, 5, 1, 4, 2]
[1, 2, 3, 4, 5].$shuffle()
=> [2, 4, 3, 5, 1]
array = [1, 2, 3, 4, 5]
array.$$shuffle()
console.log(array)
=> [4, 1, 2, 5, 3]
#Objects
({ a: 1, b: 2, c: 3, d: 4 }).$pick('a', 'd')
=> { a: 1, d: 4 }
object = { a: 1, b: 2, c: 3, d: 4 }
object.$$pick('a', 'd')
console.log(object)
=> { a: 1, d: 4 }
({ a: 1, b: 2, c: 3, d: 4 }).$keys()
=> ['a', 'b', 'c', 'd']
({ a: 1, b: 2, c: 3, d: 4 }).$values()
=> [1, 2, 3, 4]
({ a: 1, b: 2, c: 3 }).$invert()
=> { '1': 'a', '2': 'b', '3': 'c' }
object = { a: 1, b: 2, c: 3 }
object.$$invert()
console.log(object)
=> { '1': 'a', '2': 'b', '3': 'c' }
object = { a: 1, b: 2, c: 3 }
result = []
object.$each(function(k, v){ result.push(object[k]) })
console.log(result)
=> [1, 2, 3]
({ a: 1, b: 2, c: 3 }).$pairs()
=> [['a', 1], ['b', 2], ['c', 3]]
object = { a: 1, b: 2, c: function(){ return 'I am the function'; } }
object.$functions()
=> ['c']
({ a: 1, b: 2 }).$merge({ c: 3, d: 4 })
=> { a: 1, b: 2, c: 3, d: 4 }
object = { a: 1, b: 2 }
object.$$merge({ c: 3, d: 4 })
console.log(object)
=> { a: 1, b: 2, c: 3, d: 4 }
({ a: 1, b: 2, c: 3 }).$omit('b', 'c')
=> { a: 1 }
({ a: 1, b: 2, c: 3 }).$omit(['a', 'c'])
=> { b: 2 }
object = { a: 1, b: 2, c: 3 }
object.$$omit('a', 'b')
console.log(object)
=> { c: 3 }
({ a: 1, b: 2, c: 3 }).$defaults({ a: 6, e: 9 })
=> { a: 1, b: 2, c: 3, e: 9 }
object = { a: 1, b: 2, c: 3 }
object.$$defaults({ a: 6, e: 9 })
console.log(object)
=> { a: 1, b: 2, c: 3, e: 9 }
object = { a: 1, b: 2 }
object2 = object.$clone()
console.log(object2)
=> { a: 1, b: 2 }
console.log(object == object2)
=> false
object = { a: 1, b: 2 }
result = false
fn = function(){ result = true }
object.$defaults({ c: 1 }).$tap(fn).$omit('b')
=> { a: 1, c: 1 }
console.log(result)
=> true
(function(){ }).$isFunction()
=> true
({ name: 'Walter White' }).$isFunction()
=> false
[].$isArray()
=> true
(function(){ }).$isArray()
=> false
({}).$isEmpty()
=> true
({ a: 1 }).$isEmpty()
=> false
"woo".$isString()
=> true
[].$isString()
=> false
(4).$isNumber()
=> true
({}).$isNumber()
=> false
(true).$isBoolean()
=> true
("true").$isBoolean()
=> false
(new Date).$isDate()
=> true
("Date").$isDate()
=> false
{ a: 12, b: 'hey' }.$json()
=> '{"a":12,"b":"hey"}'
[1, 2, 3].$json()
=> '[1,2,3]'
#Strings
('This is a test string').$starts('This is')
=> true
('This is a test string').$starts('this is')
=> false
('This is a test string').$ends('test string')
=> true
('This is a test string').$ends('test str')
=> false
'nikola tesla'.$capitalize()
=> 'Nikola tesla'
'nikola tesla'.$titleize()
=> 'Nikola Tesla'
'2014'.$integer()
=> 2014
'2.43'.$integer()
=> 2
'2.12'.$number()
=> 2.12
'10.10.2010 10:11:12'.$date().getTime()
=> 1286694672000
'{ "a": 12, "b": "test" }'.$parse()
=> { a: 12, b: 'test' }
result = []
(5).$times(function(index){ result.push(index) })
console.log(result)
=> [0, 1, 2, 3, 4]
(1286658123123).$date()
=> Sun Oct 10 2010 00:02:03 GMT+0300 (EEST)
The MIT License (MIT)
Copyright (c) 2014 Ali Davut
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.
FAQs
missing javascript prototypes(experimental)
We found that dress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.