ramda-ruby 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/ROADMAP.md +0 -4
- data/docs/FUNCTIONS.md +1 -0
- data/lib/ramda.rb +1 -0
- data/lib/ramda/function.rb +29 -0
- data/lib/ramda/version.rb +1 -1
- data/spec/ramda/function_spec.rb +22 -0
- data/spec/ramda_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b926d96db763d6a43b3d6e114448169ebe87975
|
4
|
+
data.tar.gz: aa89681ca4ab9dfb72413e9f21dacbf9ed42a294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 288ef7275478fdd4ed28044dbfafc65ab2e366d988c4e2ce212f99cb1881522c56a9d0a4f0cc233902683c66b211abd141ee8619bf8535441f3f5213eb9aa9f6
|
7
|
+
data.tar.gz: b85a150288793a5fa4abe9e3112b2c5f2973614933af18fba0ec272db01ffd25d500f37f6c74665d3d6da3608b54c8aebd8ba743c44a26899fd2706aa96dd314
|
data/CHANGELOG.md
CHANGED
data/ROADMAP.md
CHANGED
data/docs/FUNCTIONS.md
CHANGED
data/lib/ramda.rb
CHANGED
data/lib/ramda/function.rb
CHANGED
@@ -119,6 +119,35 @@ module Ramda
|
|
119
119
|
fn.to_proc.curry
|
120
120
|
end
|
121
121
|
|
122
|
+
# Returns a curried equivalent of the provided function, with the
|
123
|
+
# specified arity. The curried function has two unusual capabilities.
|
124
|
+
# First, its arguments needn't be provided one at a time.
|
125
|
+
# If g is R.curryN(3, f), the following are equivalent:
|
126
|
+
#
|
127
|
+
# g(1)(2)(3)
|
128
|
+
# g(1)(2, 3)
|
129
|
+
# g(1, 2)(3)
|
130
|
+
# g(1, 2, 3)
|
131
|
+
#
|
132
|
+
# Secondly, the special placeholder value R.__ may be used to specify
|
133
|
+
# "gaps", allowing partial application of any combination of arguments,
|
134
|
+
# regardless of their positions.
|
135
|
+
# If g is as above and _ is R.__, the following are equivalent:
|
136
|
+
#
|
137
|
+
# g(1, 2, 3)
|
138
|
+
# g(_, 2, 3)(1)
|
139
|
+
# g(_, _, 3)(1)(2)
|
140
|
+
# g(_, _, 3)(1, 2)
|
141
|
+
# g(_, 2)(1)(3)
|
142
|
+
# g(_, 2)(1, 3)
|
143
|
+
# g(_, 2)(_, 3)(1)
|
144
|
+
#
|
145
|
+
# Number -> (* -> a) -> (* -> a)
|
146
|
+
#
|
147
|
+
curried_method(:curry_n) do |arity, fn|
|
148
|
+
Ramda::Internal::FunctionWithArity.new.call(arity, &fn).curry
|
149
|
+
end
|
150
|
+
|
122
151
|
# Returns the empty value of its argument's type. Ramda defines the empty
|
123
152
|
# value of Array ([]), Object ({}), String ('), and Arguments.
|
124
153
|
# Other types are supported if they define <Type>.empty.
|
data/lib/ramda/version.rb
CHANGED
data/spec/ramda/function_spec.rb
CHANGED
@@ -107,6 +107,28 @@ describe Ramda::Function do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
+
context '#curry_n' do
|
111
|
+
it 'from docs' do
|
112
|
+
sum_args = ->(*args) { R.sum(args) }
|
113
|
+
|
114
|
+
curried_add_four_numbers = r.curry_n(4, sum_args)
|
115
|
+
f = curried_add_four_numbers.call(1, 2)
|
116
|
+
g = f.call(3)
|
117
|
+
|
118
|
+
expect(g.call(4)).to eq(10)
|
119
|
+
end
|
120
|
+
|
121
|
+
xit 'with __' do
|
122
|
+
# g(1, 2, 3)
|
123
|
+
# g(_, 2, 3)(1)
|
124
|
+
# g(_, _, 3)(1)(2)
|
125
|
+
# g(_, _, 3)(1, 2)
|
126
|
+
# g(_, 2)(1)(3)
|
127
|
+
# g(_, 2)(1, 3)
|
128
|
+
# g(_, 2)(_, 3)(1)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
110
132
|
context '#empty' do
|
111
133
|
it 'from docs' do
|
112
134
|
expect(r.empty([1, 2, 3])).to eq([])
|
data/spec/ramda_spec.rb
CHANGED