Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ea1f74bf
Commit
ea1f74bf
authored
Feb 25, 2020
by
Shubham Pandey
Committed by
Kushal Pandya
Feb 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] Replace underscore with lodash in app/assets/javascripts/lib
parent
4ecc362c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
11 deletions
+15
-11
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+5
-5
app/assets/javascripts/lib/utils/highlight.js
app/assets/javascripts/lib/utils/highlight.js
+3
-4
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+2
-2
changelogs/unreleased/196648-replace-_-with-lodash.yml
changelogs/unreleased/196648-replace-_-with-lodash.yml
+5
-0
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
ea1f74bf
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
_
from
'
underscore
'
;
import
{
isString
,
mapValues
,
isNumber
,
reduce
}
from
'
lodash
'
;
import
*
as
timeago
from
'
timeago.js
'
;
import
*
as
timeago
from
'
timeago.js
'
;
import
dateFormat
from
'
dateformat
'
;
import
dateFormat
from
'
dateformat
'
;
import
{
languageCode
,
s__
,
__
,
n__
}
from
'
../../locale
'
;
import
{
languageCode
,
s__
,
__
,
n__
}
from
'
../../locale
'
;
...
@@ -79,7 +79,7 @@ export const getDayName = date =>
...
@@ -79,7 +79,7 @@ export const getDayName = date =>
* @returns {String}
* @returns {String}
*/
*/
export
const
formatDate
=
(
datetime
,
format
=
'
mmm d, yyyy h:MMtt Z
'
)
=>
{
export
const
formatDate
=
(
datetime
,
format
=
'
mmm d, yyyy h:MMtt Z
'
)
=>
{
if
(
_
.
isString
(
datetime
)
&&
datetime
.
match
(
/
\d
+-
\d
+
\d
+ /
))
{
if
(
isString
(
datetime
)
&&
datetime
.
match
(
/
\d
+-
\d
+
\d
+ /
))
{
throw
new
Error
(
__
(
'
Invalid date
'
));
throw
new
Error
(
__
(
'
Invalid date
'
));
}
}
return
dateFormat
(
datetime
,
format
);
return
dateFormat
(
datetime
,
format
);
...
@@ -497,7 +497,7 @@ export const parseSeconds = (
...
@@ -497,7 +497,7 @@ export const parseSeconds = (
let
unorderedMinutes
=
Math
.
abs
(
seconds
/
SECONDS_PER_MINUTE
);
let
unorderedMinutes
=
Math
.
abs
(
seconds
/
SECONDS_PER_MINUTE
);
return
_
.
mapObject
(
timePeriodConstraints
,
minutesPerPeriod
=>
{
return
mapValues
(
timePeriodConstraints
,
minutesPerPeriod
=>
{
if
(
minutesPerPeriod
===
0
)
{
if
(
minutesPerPeriod
===
0
)
{
return
0
;
return
0
;
}
}
...
@@ -516,7 +516,7 @@ export const parseSeconds = (
...
@@ -516,7 +516,7 @@ export const parseSeconds = (
* If the 'fullNameFormat' param is passed it returns a non condensed string eg '1 week 3 days'
* If the 'fullNameFormat' param is passed it returns a non condensed string eg '1 week 3 days'
*/
*/
export
const
stringifyTime
=
(
timeObject
,
fullNameFormat
=
false
)
=>
{
export
const
stringifyTime
=
(
timeObject
,
fullNameFormat
=
false
)
=>
{
const
reducedTime
=
_
.
reduce
(
const
reducedTime
=
reduce
(
timeObject
,
timeObject
,
(
memo
,
unitValue
,
unitName
)
=>
{
(
memo
,
unitValue
,
unitName
)
=>
{
const
isNonZero
=
Boolean
(
unitValue
);
const
isNonZero
=
Boolean
(
unitValue
);
...
@@ -642,7 +642,7 @@ export const dayAfter = date => new Date(newDate(date).setDate(date.getDate() +
...
@@ -642,7 +642,7 @@ export const dayAfter = date => new Date(newDate(date).setDate(date.getDate() +
* @return {String} approximated time
* @return {String} approximated time
*/
*/
export
const
approximateDuration
=
(
seconds
=
0
)
=>
{
export
const
approximateDuration
=
(
seconds
=
0
)
=>
{
if
(
!
_
.
isNumber
(
seconds
)
||
seconds
<
0
)
{
if
(
!
isNumber
(
seconds
)
||
seconds
<
0
)
{
return
''
;
return
''
;
}
}
...
...
app/assets/javascripts/lib/utils/highlight.js
View file @
ea1f74bf
import
fuzzaldrinPlus
from
'
fuzzaldrin-plus
'
;
import
fuzzaldrinPlus
from
'
fuzzaldrin-plus
'
;
import
_
from
'
underscore
'
;
import
sanitize
from
'
sanitize-html
'
;
import
sanitize
from
'
sanitize-html
'
;
/**
/**
...
@@ -17,11 +16,11 @@ import sanitize from 'sanitize-html';
...
@@ -17,11 +16,11 @@ import sanitize from 'sanitize-html';
* @param {String} matchSuffix The string to insert at the end of a match
* @param {String} matchSuffix The string to insert at the end of a match
*/
*/
export
default
function
highlight
(
string
,
match
=
''
,
matchPrefix
=
'
<b>
'
,
matchSuffix
=
'
</b>
'
)
{
export
default
function
highlight
(
string
,
match
=
''
,
matchPrefix
=
'
<b>
'
,
matchSuffix
=
'
</b>
'
)
{
if
(
_
.
isUndefined
(
string
)
||
_
.
isNull
(
string
)
)
{
if
(
!
string
)
{
return
''
;
return
''
;
}
}
if
(
_
.
isUndefined
(
match
)
||
_
.
isNull
(
match
)
||
match
===
''
)
{
if
(
!
match
)
{
return
string
;
return
string
;
}
}
...
@@ -34,7 +33,7 @@ export default function highlight(string, match = '', matchPrefix = '<b>', match
...
@@ -34,7 +33,7 @@ export default function highlight(string, match = '', matchPrefix = '<b>', match
return
sanitizedValue
return
sanitizedValue
.
split
(
''
)
.
split
(
''
)
.
map
((
character
,
i
)
=>
{
.
map
((
character
,
i
)
=>
{
if
(
_
.
contains
(
occurrences
,
i
))
{
if
(
occurrences
.
includes
(
i
))
{
return
`
${
matchPrefix
}${
character
}${
matchSuffix
}
`
;
return
`
${
matchPrefix
}${
character
}${
matchSuffix
}
`
;
}
}
...
...
app/assets/javascripts/lib/utils/text_utility.js
View file @
ea1f74bf
import
_
from
'
underscore
'
;
import
{
isString
}
from
'
lodash
'
;
/**
/**
* Adds a , to a string composed by numbers, at every 3 chars.
* Adds a , to a string composed by numbers, at every 3 chars.
...
@@ -199,7 +199,7 @@ export const splitCamelCase = string =>
...
@@ -199,7 +199,7 @@ export const splitCamelCase = string =>
* i.e. "My Group / My Subgroup / My Project"
* i.e. "My Group / My Subgroup / My Project"
*/
*/
export
const
truncateNamespace
=
(
string
=
''
)
=>
{
export
const
truncateNamespace
=
(
string
=
''
)
=>
{
if
(
_
.
isNull
(
string
)
||
!
_
.
isString
(
string
))
{
if
(
string
===
null
||
!
isString
(
string
))
{
return
''
;
return
''
;
}
}
...
...
changelogs/unreleased/196648-replace-_-with-lodash.yml
0 → 100644
View file @
ea1f74bf
---
title
:
Replaced underscore with lodash for app/assets/javascripts/lib
merge_request
:
25042
author
:
Shubham Pandey
type
:
other
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment