How to use the lodash-es.forEach function in lodash-es

To help you get started, we’ve selected a few lodash-es examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Sunbird-Ed / SunbirdEd-portal / src / app / client / src / app / modules / cbse-program / components / question-list / question-list.component.ts View on Github external
public publishQuestions() {
    let selectedQuestions = _.filter(this.questionList, (question) => _.get(question, 'isSelected'));
    this.publishInProgress = true;
    this.publishButtonStatus.emit(this.publishInProgress);
    let selectedQuestionsData = _.reduce(selectedQuestions, (final, question) => {
      final.ids.push(_.get(question, 'identifier'));
      final.author.push(_.get(question, 'author'));
      final.category.push(_.get(question, 'category'));
      final.attributions = _.union(final.attributions, _.get(question, 'organisation'));
      return final;
    }, { ids: [], author: [], category: [], attributions: [] });

    if (selectedQuestionsData.ids.length > 0) {
      const questions = [];
      _.forEach(_.get(selectedQuestionsData, 'ids'), (value) => {
        questions.push({ 'identifier': value });
      });
      this.cbseService.getECMLJSON(selectedQuestionsData.ids).subscribe((theme) => {
        let creator = this.userService.userProfile.firstName;
        if (!_.isEmpty(this.userService.userProfile.lastName)) {
          creator = this.userService.userProfile.firstName + ' ' + this.userService.userProfile.lastName;
        }

        const option = {
          url: `private/content/v3/create`,
          data: {
            'request': {
              'content': {
                // tslint:disable-next-line:max-line-length
                'name': this.resourceName || `${this.questionTypeName[this.selectedAttributes.questionType]} - ${this.selectedAttributes.topic}`,
                'contentType': this.selectedAttributes.questionType === 'curiosity' ? 'CuriosityQuestionSet' : 'PracticeQuestionSet',
github Yoast / YoastSEO.js / src / researches / french / passiveVoice / FrenchParticiple.js View on Github external
var getExceptionsParticiplesNounsRegexes = memoize( function() {
	let exceptionsParticiplesNounsRegexes = [];

	// Nouns starting with a vowel are checked with -s suffix and l' and d' prefixes.
	forEach( exceptionsParticiplesNounsVowel, function( exceptionParticipleNounVowel ) {
		exceptionsParticiplesNounsRegexes.push( new RegExp( "^(l'|d')?" + exceptionParticipleNounVowel + "(s)?$", "ig" ) );
	} );
	// Nouns starting with a consonant are checked with -s suffix.
	forEach( exceptionsParticiplesNounsConsonant, function( exceptionParticipleNounConsonant ) {
		exceptionsParticiplesNounsRegexes.push( new RegExp( "^" + exceptionParticipleNounConsonant + "(s)?$", "ig" ) );
	} );

	return exceptionsParticiplesNounsRegexes;
} );
github Yoast / YoastSEO.js / src / researches / french / passiveVoice / FrenchParticiple.js View on Github external
var getExceptionsParticiplesAdjectivesVerbsRegexes = memoize( function() {
	let exceptionsParticiplesAdjectivesVerbsRegexes = [];
	forEach( exceptionsParticiplesAdjectivesVerbs, function( exceptionParticiplesAdjectivesVerbs ) {
		exceptionsParticiplesAdjectivesVerbsRegexes.push( new RegExp( "^" + exceptionParticiplesAdjectivesVerbs + "(e|s|es)?$", "ig" ) );
	} );
	return exceptionsParticiplesAdjectivesVerbsRegexes;
} );
github Yoast / wordpress-seo / js / src / wp-seo-replacevar-plugin.js View on Github external
YoastReplaceVarPlugin.prototype.replaceByStore = function( data ) {
		const replacementVariables = this._store.getState().snippetEditor.replacementVariables;

		forEach( replacementVariables, ( replacementVariable ) => {
			if ( replacementVariable.value === "" ) {
				return;
			}

			data = data.replace( "%%"  + replacementVariable.name + "%%", replacementVariable.value );
		} );

		return data;
	};
github Sunbird-Ed / SunbirdEd-portal / src / app / client / src / app / modules / learn / services / courseProgress / course-progress.service.ts View on Github external
private calculateProgress(courseId_batchId) {
    const lastAccessTimeOfContentId = [];
    let completedCount = 0;
    const contentList = this.courseProgress[courseId_batchId].content;
    _.forEach(contentList, (content) => {
      if (content.status === 2) {
        completedCount += 1;
      }
      if (content.lastAccessTime) {
        lastAccessTimeOfContentId.push(content.lastAccessTime);
      }
    });
    this.courseProgress[courseId_batchId].completedCount = completedCount;
    const progress = ((this.courseProgress[courseId_batchId].completedCount / this.courseProgress[courseId_batchId].totalCount) * 100);
    this.courseProgress[courseId_batchId].progress = progress > 100 ? 100 : progress;
    const index = _.findIndex(contentList, { lastAccessTime: lastAccessTimeOfContentId.sort().reverse()[0] });
    const lastPlayedContent = contentList[index] ? contentList[index] : contentList[0];
    this.courseProgress[courseId_batchId].lastPlayedContentId = lastPlayedContent && lastPlayedContent.contentId;
  }
github Sunbird-Ed / SunbirdEd-portal / src / app / client / projects / desktop / src / app / modules / offline / components / desktop-explore-content / desktop-explore-content.component.ts View on Github external
prepareVisits() {
    const visits = [];
    _.forEach(this.contentList, (content, index) => {
      visits.push({
        objid: content.metaData.identifier,
        objtype: content.metaData.contentType,
        index: index,
      });
    });

    this.telemetryImpression.edata.visits = visits;
    this.telemetryImpression.edata.subtype = 'pageexit';
    this.telemetryImpression = Object.assign({}, this.telemetryImpression);
  }
github raindropio / mobile / src / data / reducers / bookmarks / draft.js View on Github external
.setIn(
				['drafts', 'byId', newItem._id],
				blankDraft
					.set('status', 'loaded')
					.set('item', newItem)
			)
	}

	//Update drafts also
	case BOOKMARK_UPDATE_SUCCESS:{
		if (state.drafts.byId[action._id]){
			const updatedItem = normalizeBookmark(action.item, {flat: false})
			const draftItem = state.getIn(['drafts', 'byId', action._id, 'item'])

			if (draftItem)
			_.forEach(updatedItem, (val,field)=>{
				if (val != draftItem[field])
					state = state.setIn(['drafts', 'byId', action._id, 'item', field], updatedItem[field])
			})

			state = state.setIn(['drafts', 'byId', action._id, 'status'], updatedItem.collectionId!=-99 ? 'loaded' : 'removed')
		}

		return state
	}

	//Remove draft
	case BOOKMARK_REMOVE_SUCCESS:{
		if (state.drafts.byId[action._id])
			return state.setIn(['drafts', 'byId', action._id, 'status'], 'removed')

		return state
github Sunbird-Ed / SunbirdEd-portal / src / app / client / src / app / modules / workspace / components / batch-page-section / batch-page-section.component.ts View on Github external
_.forEach(sections, (section, sectionIndex) => {
          _.forEach(section.contents, (content, contentIndex) => {
            sections[sectionIndex].contents[contentIndex]['userName'] = (userNamesKeyById[content.createdBy].firstName || '')
            + ' ' + (userNamesKeyById[content.createdBy].lastName || '');
            sections[sectionIndex].contents[contentIndex]['metaData'] = {identifier: content.identifier};
            sections[sectionIndex].contents[contentIndex]['label'] = content.participantCount || 0;
          });
        });
        this.carouselData = sections;
github Sunbird-Ed / SunbirdEd-portal / src / app / client / src / app / modules / workspace / components / batch-page-section / batch-page-section.component.ts View on Github external
.subscribe((res: ServerResponse) => {
      if (res.result.response.count && res.result.response.content.length > 0) {
        const userNamesKeyById = _.keyBy(res.result.response.content, 'identifier');
        _.forEach(sections, (section, sectionIndex) => {
          _.forEach(section.contents, (content, contentIndex) => {
            sections[sectionIndex].contents[contentIndex]['userName'] = (userNamesKeyById[content.createdBy].firstName || '')
            + ' ' + (userNamesKeyById[content.createdBy].lastName || '');
            sections[sectionIndex].contents[contentIndex]['metaData'] = {identifier: content.identifier};
            sections[sectionIndex].contents[contentIndex]['label'] = content.participantCount || 0;
          });
        });
        this.carouselData = sections;
        this.showLoader = false;
      } else {
        this.toasterService.error(this.resourceService.messages.fmsg.m0056);
      }
    },
      (err: ServerResponse) => {
github Yoast / YoastSEO.js / src / stringProcessing / syllables / count.js View on Github external
var countPartialWordDeviations = function( word, locale ) {
	var deviationFragments = createDeviationFragmentsMemoized( syllableMatchers( locale ) );
	var remainingParts = word;
	var syllableCount = 0;

	forEach( deviationFragments, function( deviationFragment ) {
		if ( deviationFragment.occursIn( remainingParts ) ) {
			remainingParts = deviationFragment.removeFrom( remainingParts );
			syllableCount += deviationFragment.getSyllables();
		}
	} );

	return { word: remainingParts, syllableCount: syllableCount };
};